You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(24) |
Sep
(14) |
Oct
(13) |
Nov
(5) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(2) |
Feb
(53) |
Mar
(29) |
Apr
(5) |
May
(11) |
Jun
(3) |
Jul
(7) |
Aug
(48) |
Sep
(10) |
Oct
(8) |
Nov
(1) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
(2) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <aca...@us...> - 2008-05-29 16:44:17
|
Revision: 178 http://gridsim.svn.sourceforge.net/gridsim/?rev=178&view=rev Author: acaminero Date: 2008-05-29 09:44:20 -0700 (Thu, 29 May 2008) Log Message: ----------- add gridsim.net.fnb package for incorporating finite net buffers in routers Added Paths: ----------- branches/gridsim4.0-branch2/source/gridsim/net/fnb/ branches/gridsim4.0-branch2/source/gridsim/net/fnb/ARED.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FIFO.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedPacketInfo.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedUserPacket.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbEndToEndPath.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbInput.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetPacket.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetworkReader.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbOutput.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbRIPRouter.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbRouter.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbSCFQScheduler.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/RED.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/firstLastPacketsGridlet.java branches/gridsim4.0-branch2/source/gridsim/net/fnb/source_pktNum.java Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/ARED.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/ARED.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/ARED.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,213 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and distributed Systems such as Lcusters and Grids + * License: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: ARED.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + +package gridsim.net.fnb; + +import gridsim.GridSim; +import java.io.FileWriter; +import gridsim.net.Link; + +/** + * This class implements the Adaptative Random Early Detection policy for the management + * of netwrk buffers at routers. + * Its basic functionality is as follows: + * - There is a ARED object at each outport in routers. + * - For each incoming packet that reaches that outport port, the policy + * decides whether it is enqueued or dropped. This is done by calculating the + * average buffer size and comparing it with two thresholds. + * - If the packet is dropped, and it is not a junk packet, we must inform the + * user involved in the transmission about the dropping. + * + * For more details refer to A. Caminero's ANSS'08 paper <i> "Simulation of + * Buffer Management Policies in Networks for Grids" </i> + * + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + * */ +public class ARED extends RED +{ + /** Decrease factor*/ + private double BETA; + + /** Increment*/ + private double ALPHA; + + /** Target for AVG */ + private double TARGET_LOW; + + /** Target for AVG*/ + private double TARGET_HIGH; + + + /** + * Creates a new SCFQ packet scheduler + * @param max_buf_size maximum buffer size for routers + * @throws ParameterException This happens when the baud rate <= 0 + * @pre baudRate > 0 + * @post $none + */ + public ARED(String name, double baudRate, double max_p, int max_buf_size, + double queue_weight, boolean stats) throws Exception + { + super(name, baudRate, max_buf_size, 0.0, 0.0, max_p, queue_weight, stats); + + initialize(); + + } + + + /** + * This function updates the value of max_p, which is the maximum dropping + * probability for a packet. + * It also updates ALPHA, as it depends on max_p. */ + public void updateAREDParameters() + { + double max_p = getMaxP(); + if ((getAvg() > TARGET_HIGH) && (getMaxP() <= 0.5)) + { + // increase max_p + + setMaxP(max_p + ALPHA); + + } + else if ((getAvg() < TARGET_LOW) && (max_p >= 0.01)) + { + // decrease max_p + setMaxP(max_p * BETA); + } + + if ((max_p / 4) < 0.01) + ALPHA = max_p / 4; + else + ALPHA = 0.01; + + } + + /** Update the stats file of this scheduler. + */ + public void updateStats() + { + fw_write(GridSim.clock() + "\t" + getMaxP() + "\t" + getMinTh() + "\t" + + getMaxTh() + "\t" + getAvg() + "\t" + this.size() + "\n", + this.getSchedName() + "_Buffers"); + } + + + /** + * This methods sets some parameters for the RED and ARED algorithms, + * such as the thresholds. + * + */ + public void setThresholds() + { + double minTh; + + double C = super.getBaudRate() / (Link.DEFAULT_MTU * 8); + // baudRate_is in bits per second, MTU is in bytes. + + double term = -1 / C; + double term2 = Math.exp(term); + + setQueueWeight(1 - term2); + + double DELAY_TARGET = 0.005; // 5 milliseconds + double var = DELAY_TARGET * C / 2; + + if (5 > var) + { + minTh = 5; + } + else + { + minTh = var; + + } + + setMinTh(minTh); + setMaxTh(3 * minTh); + + } + + /**This function initializes the parameters of the buffers policies + * */ + public void initialize() + { + super.initialize(); + + setThresholds(); + + if ((getMaxP() / 4) < 0.01) + ALPHA = getMaxP() / 4; + else + ALPHA = 0.01; + + BETA = 0.9; + + } + + + /** + * Sets the baud rate that this scheduler will be sending packets at. + * @param rate the baud rate of this scheduler (in bits/s) + * @pre rate > 0 + * @post $none + */ + public boolean setBaudRate(double rate) + { + + if (rate <= 0.0) + { + return false; + } + super.setBaudRateSCFQ(rate); + + initialize(); + + return true; + } + + /** + * Prints out the given message into stdout. + * In addition, writes it into a file. + * @param msg a message + * @param file file where we want to write + */ + private static void fw_write(String msg, String file) + { + FileWriter fwriter = null; + + try + { + fwriter = new FileWriter(file, true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while opening file " + file); + } + + try + { + fwriter.write(msg); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while writing on file " + file); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while closing file " + file); + } + } + +} Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FIFO.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FIFO.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FIFO.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,358 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and distributed Systems such as Lcusters and Grids + * License: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: FIFO.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + +package gridsim.net.fnb; + +import gridsim.net.fnb.*; +import gridsim.net.Packet; +import gridsim.GridSimTags; +import gridsim.ParameterException; +import gridsim.GridSim; +import java.io.FileWriter; +import gridsim.net.*; + +/** + * This class implements the FIFO policy for the management + * of netwrk buffers at routers. + * Its basic functionality is as follows: + * - There is a FIFO object at each outport in routers. + * - For each incoming packet that reaches that outport port, the policy + * decides whether it is enqueued or dropped. This is done by calculating the + * average buffer size and comparing it with two thresholds. + * - If the packet is dropped, and it is not a junk packet, we must inform the + * user involved in the transmission about the dropping. + * + * For more details refer to A. Caminero's ANSS'08 paper <i> "Simulation of + * Buffer Management Policies in Networks for Grids" </i> + * + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + * */ +public class FIFO extends FnbSCFQScheduler +{ + + private double QUEUE_WEIGHT; // the queue weigth + private double AVG; + private double Q_TIME; + private double S; + + + public double MAX_AVG = 0.0; + + + /** + * Creates a new SCFQ packet scheduler with the specified name and baud rate + * (in bits/s). The name can be useful for debugging purposes, but serves + * no functional purposes. + * + * @param name Name of this scheduler + * @param baudRate baud rate in bits/s of the port that is using + * this scheduler. + * @param max_buf_size maximum buffer size for routers + * @throws ParameterException This happens when the name is null or + * the baud rate <= 0 + * @pre name != null + * @pre baudRate > 0 + * @post $none + */ + public FIFO(String name, double baudRate, int max_buf_size, + double queue_weight, boolean stats) throws Exception + { + super(name, baudRate, max_buf_size, stats); + + QUEUE_WEIGHT = queue_weight; + + if (name == null) + { + throw new ParameterException("RED(): Name is null."); + } + + if (baudRate <= 0) + { + throw new ParameterException("RED(): Baudrate <= 0."); + } + + initialize(); + + } + + + /** + * Checks queue size and puts a packet into the queue + * + * @param pnp A Packet to be enqued by this scheduler. + * @return <tt>true</tt> if enqued, <tt>false</tt> otherwise + * @pre pnp != null + * @post $none + */ + public synchronized boolean enque(Packet pnp) + { + /*double clock = GridSim.clock(); + if (clock > nextInterval) + { + updateAFIFOParameters(); + nextInterval = clock + INTERVAL; + }*/ + + checkAndInsertPacketIntoQueue(pnp); /// insert the pkt into the queue + + //double avgQueueSize = avgQueueSize(); + + return true; + + } // public synchronized boolean enque(Packet pnp) + + + /** + * Puts a packet into the queue, checking the queue size before that. + * + * @param pnp A Packet to be enqued by this scheduler. + * @return <tt>true</tt> if enqued, <tt>false</tt> otherwise + * @pre pnp != null + * @post $none + */ + public synchronized boolean checkAndInsertPacketIntoQueue(Packet pnp) + { + + if (size() < getMaxBufferSizeInPkts()) + { + insertPacketIntoQueue(pnp); + return true; + } + else + { + dropPacketFIFO(pnp); + return false; + } + } + + /** If the queue is full, we have to drop a packet. + * If the packet to get dropped is a control packet, the sim will stop. + * Control packets will be those packets sent between the broker or the gis. + * Normal packets are those belonging to a gridlet. + * We are using the FIFO algorithm. + * @param pnp the new incoming packet + * */ + public synchronized boolean dropPacketFIFO(Packet pnp) + { + // If the queue is full, we have to drop a packet, giving priority to the control packets + // Control packets will be those packets sent between the broker or the gis. + // Normal packets are those belonging to a gridlet. + // Control packets can only be dropped when the wue is full of control packets + + increaseDroppedPktCounter(); // increase the counter of dropped packets + + // First: check if the new incoming packet is a control packet or not. + + // Check the source of the packet + int src_outputPort = ((FnbNetPacket) pnp).getSrcID(); + String src_outputPort_str = GridSim.getEntityName( + src_outputPort); + // for example, src_outputPort_str = Output_SIM_0_User_0 + + // Check the destination, as I'm not sure if it works like that + int dst = ((FnbNetPacket) pnp).getDestID(); + String dst_str = GridSim.getEntityName(dst); + + // If one of the ends of this packet is the broker or the GIS + if ((src_outputPort_str.indexOf("Broker") != -1) || + (dst_str.indexOf("Broker") != -1) || + (src_outputPort_str.indexOf("GIS") != -1) || + (dst_str.indexOf("GIS") != -1)) + { + + /* + // This was the very first version of the Fnbs + insertPacketIntoQueue(pnp); + return true;*/ + + if (makeRoomForPacket()) + { + // If we have been able of dropping a data packet, then we have room for this control packet + insertPacketIntoQueue(pnp); + } + else + { + // The control packet has to be dropped. + + System.out.println("\n" + super.get_name() + + ": buffer full, and a control packet has been dropped.\n" + + " src.output: " + src_outputPort_str + + ". dst_inputPort: " + dst_str + + "\n HENCE, SIMULATION FINISHED"); + + System.exit(1); + // super.shutdownUserEntity(); + // super.terminateIOEntities(); + + return false; + } + } + + /* + // If u want more info on the progress of sims, uncomment this. + System.out.println(super.get_name() + ": packet dropped. Src: " + + src_outputPort_str + ", Dst: " + dst_str + + ". Pkt num: " + ((FnbNetPacket) pnp).getPacketNum());*/ + + // In this case, we will have to remove the packet, and + // also, we will have to tell the source of the packet what has happened. + // The source of a packet is the user/resource which sent it. + // So, in order to contact the entity, we do it through its output port. + // This is done through an event, not through the network + + int entity; + if (src_outputPort_str.indexOf("User") != -1) + { + // if the src of the packet is an user, tell him what has happened + + // NOTE: this is a HACK job. "Output_" has 7 chars. So, + // the idea is to get only the entity name by removing + // "Output_" word in the outName string. + String src_str = src_outputPort_str.substring(7); + // for example, src_str = SIM_0_User_0 + + entity = GridSim.getEntityId(src_str); + + } + else + { + // If the destination of the packet is the user, tell the user + + entity = GridSim.getEntityId(dst_str); + + } + + int pktID = ((FnbNetPacket) pnp).getID(); + + // String input_src_str = "Input_" + src_str; + // for example, input_src_str = Input_SIM_0_User_0 + // int input_src = GridSim.getEntityId(input_src_str); + + super.send(src_outputPort, GridSimTags.SCHEDULE_NOW, + GridSimTags.FNB_PACKET_DROPPED, + new FnbDroppedUserPacket(entity, pktID)); + // We tell the output entity of the sender of this packet + // that the packet has been dropped. + + pnp = null; // remove the packet. + + return true; + + } + + + /** Calculate the avg queue size for the FIFO algorithm. + * */ + public double avgQueueSize() + { + + int q = size(); + double time = GridSim.clock(); + + // Only this if is necesary for the algo + if (q != 0) + { + AVG = AVG + QUEUE_WEIGHT * (q - AVG); + } + else + { + AVG = Math.pow((1 - QUEUE_WEIGHT), (time - Q_TIME) / S) * AVG; + } + + if (AVG > MAX_AVG) + MAX_AVG = AVG; + + return AVG; + + } // avgQueueSize() + + + /** + * Prints out the given message into stdout. + * In addition, writes it into a file. + * @param msg a message + * @param file file where we want to write + */ + private static void fw_write(String msg, String file) + { + //System.out.print(msg); + FileWriter fwriter = null; + + try + { + fwriter = new FileWriter(file, true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while opening file " + file); + } + + try + { + fwriter.write(msg); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while writing on file " + file); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while closing file " + file); + } + } + + /**This function initializes the parameters of the buffers policies (RED, ARED) + * */ + public void initialize() + { + // empty + + + } + + /** + * Sets the baud rate that this scheduler will be sending packets at. + * @param rate the baud rate of this scheduler (in bits/s) + * @pre rate > 0 + * @post $none + */ + public boolean setBaudRate(double rate) + { + + if (rate <= 0.0) + { + return false; + } + super.setBaudRateSCFQ(rate); + + return true; + } + + /** Returns the avg buffer size*/ + public double getAvg() + { + return AVG; + } + + /** Update the stats file of this scheduler. + */ + public void updateStats() + { + fw_write(GridSim.clock() + "\t\t\t\t" + AVG + "\t" + this.size() + "\n", + this.getSchedName() + "_Buffers"); + } + + +} Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedPacketInfo.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedPacketInfo.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedPacketInfo.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,56 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + $Id: glID_userID.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + + package gridsim.net.fnb; + +// fixme - TODO check whether can be used for dropping replicas or datasets + +/**This class is used by routers when they inform users of the dropping of a packet. + * Thus, routers tell users which gridlet got the dropped packet. This is done + * to minimize the network overhead caused by this informations. + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + */ +public class FnbDroppedPacketInfo +{ + private int glID; // TODO try to be more general, not just gridlet + + private int userID; + + + + /**Creates a new object of this class. This is used by FnbSCFQScheduler + * @param g the gridlet id + * @param u user id + * */ + public FnbDroppedPacketInfo(int g, int u) + { + glID = g; + userID = u; + } + + + /** Gets the gridlet id. + * @return the gridlet id. + * */ + public int getGlID() + { + return glID; + } + + + /** Gets the user id. + * @return the user id. + * */ + public int getUserID() + { + return userID; + } + +} Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedUserPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedUserPacket.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbDroppedUserPacket.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,167 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + $Id: userPacket.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + +package gridsim.net.fnb; + +import gridsim.net.*; + +/** + * This class is for the routers to tell users when one of their packets is dropped. + * @author Agustin Caminero, Universidad de Castilla La Mancha (Spain). + * @since GridSim Toolkit 4.1 + * */ +public class FnbDroppedUserPacket implements Packet +{ + int userID; + int pktID; + + /**Create an object of this class. + * @param userID the user id + * @param pktID the packet id */ + public FnbDroppedUserPacket(int userID, int pktID) + { + this.userID= userID; + this.pktID= pktID; + } + + + /** Gets the user id + * @return user id */ + public int getUser() + { + return userID; + } + + + /** Gets the packet id + * @return packet id */ + public int getPkt() + { + return pktID; + } + + + /** + * Gets this packet tag + * @return this packet tag + * @pre $none + * @post $none + */ + public int getTag() + { + return -1; + } + + /** + * Sets an entity ID from the last hop that this packet has traversed. + * @param last an entity ID from the last hop + * @pre last > 0 + * @post $none + */ + public void setLast(int last) + { + + } + + /** + * Gets an entity ID from the last hop that this packet has traversed. + * @return an entity ID + * @pre $none + * @post $none + */ + public int getLast() + { + return -1; + } + + + /** + * Sets the network service type of this packet. + * <p> + * By default, the service type is 0 (zero). It is depends on the packet + * scheduler to determine the priority of this service level. + * @param serviceType this packet's service type + * @pre serviceType >= 0 + * @post $none + */ + public void setNetServiceType(int serviceType) + { + + } + + /** + * Gets the network service type of this packet + * @return the network service type + * @pre $none + * @post $none + */ + public int getNetServiceType() + { + return -1; + } + + + /** + * Returns the ID of the source of this packet. + * @return source id + * @pre $none + * @post $none + */ + public int getSrcID() + { + return -1; + } + + + /** + * Returns the ID of this packet + * @return packet ID + * @pre $none + * @post $none + */ + public int getID() + { + return pktID; + } + + + /** + * Returns the destination id of this packet. + * @return destination id + * @pre $none + * @post $none + */ + public int getDestID() + { + return -1; + } + + /** + * Sets the size of this packet + * @param size size of the packet + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre size >= 0 + * @post $none + */ + public boolean setSize(long size) + { + return false; + } + + /** + * Returns the size of this packet + * @return size of the packet + * @pre $none + * @post $none + */ + public long getSize() + { + return -1; + } +} Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbEndToEndPath.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbEndToEndPath.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbEndToEndPath.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,154 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + $Id: FnbNetPacket.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + +package gridsim.net.fnb; + + /** + * This class keeps some information which are common to all the packets of a gridlet. + * When a packet is dropped in a router, the router must inform the user/owner + * about this scenario. + * Since many packets from the same gridlet may get dropped, the router only sends + * one event for the whole process, not for each dropped packet. + * Thus, we put all of the common information (e.g. source and destination IDs) + * into this class. + * + * @since GridSim Toolkit 4.1 + * @author Agustin Caminero + */ +public class FnbEndToEndPath +{ + private int destID; + private int srcID; + private int classtype; + private int totalPkts; // total num of packet that belongs to a group + private int glID; // the id of the gridlet this packet belongs to + + /**Creates a new object of this class. Tihs is used in the FnbOutput class. + * @param destID destination id + * @param sourceID source id + * @param classType network service level + * @param totalPkts total number of packets this connection is made of + * @param glID the gridlet id + * */ + public FnbEndToEndPath (int destID, int srcID, int classtype, int totalPkts, int glID) + { + this.destID = destID; + this.srcID = srcID; + this.classtype = classtype; + this.totalPkts = totalPkts; + this.glID = glID; + } + + + /**Creates a new object of this class. Tihs is used in the FnbOutput class. + * @param destID destination id + * @param sourceID source id + * @param classType network service level + * @param totalPkts total number of packets this connection is made of + * @param glID the gridlet id + * */ + public FnbEndToEndPath (int destID, int srcID, int classtype, int totalPkts) + { + this.destID = destID; + this.srcID = srcID; + this.classtype = classtype; + this.totalPkts = totalPkts; + this.glID = -1; + } + + /** Sets the destination id for a connection. + * @param d the destination id + * */ + public void setDest(int d) + { + destID = d; + } + + + /** Sets the source id for a connection. + * @param s the source id + * */ + public void setSrc(int s) + { + srcID = s; + } + + + /** Sets the network service level (or classtype) for a connection. + * @param c the network service level id + * */ + public void setClasstype(int c) + { + classtype = c; + } + + + /** Sets the total packets for a connection. + * @param t total packets + * */ + public void setTotalPkts(int t) + { + totalPkts = t; + } + + /** Gets the source id of a connection. + * @return the source id of the connection + * */ + public int getSrc() + { + return srcID; + } + + + /** Gets the destination id of a connection. + * @return the destination id of the connection + * */ + public int getDest() + { + return destID; + } + + + + /** Gets the classtype of a connection. + * @return the classtype of the connection + * */ + public int getClasstype() + { + return classtype; + } + + + + /** Gets the total number of packets of a connection. + * @return the total number of packets of the connection + * */ + public int getTotalPkts() + { + return totalPkts; + } + + + /** Sets the gridlet id of a connection. + * @param g the gridlet id of the connection + * */ + public void setGlID(int g) + { + glID = g; + } + + + /** Gets the gridlet id of a connection. + * @return the gridlet id of the connection + * */ + public int getGlID() + { + return glID; + } +} Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbInput.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbInput.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbInput.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,543 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and distributed Systems such as Lcusters and Grids + * License: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: FnbInput.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + +package gridsim.net.fnb; + +import gridsim.net.fnb.*; +import gridsim.*; +import gridsim.net.*; +import eduni.simjava.*; +import java.util.*; +import java.io.FileWriter; +import gridsim.util.TrafficGenerator; + +/** + * GridSim FnbInput class defines a port through which a simulation entity + * receives data from the simulated network. + * <p> + * It maintains an event queue + * to serialize the data-in-flow and delivers to its parent entity. + * It accepts messages that comes from GridSim entities 'FnbOutput' entity + * and passes the same to the GridSim entity. + * It simulates Network communication delay depending on Baud rate + * and data length. Simultaneous inputs can be modeled using multiple + * instances of this class. + * + * @author Agustin Caminero, Universidad de Castilla La Mancha (Spain). + * Based on Input class, by Manzur Murshed and Rajkumar Buyya. + * @since GridSim Toolkit 4.1 + * + * Things added or modifyed: + * - getDataFromLink(...) + * - source_PktNum_array + * - FnbNetPacket instead of NetPacket + * + */ +public class FnbInput extends Sim_entity implements NetIO +{ + private Sim_port inPort_; + private Link link_; + private double baudRate_; + private static final int BITS = 8; // 1 byte = 8 bits + + private ArrayList source_PktNum_array; + + /** + * Allocates a new Input object + * @param name the name of this object + * @param baudRate the communication speed + * @throws NullPointerException This happens when creating this entity + * before initializing GridSim package or this entity name + * is <tt>null</tt> or empty + * @pre name != null + * @pre baudRate >= 0.0 + * @post $none + */ + public FnbInput(String name, double baudRate) throws NullPointerException + { + super(name); + this.baudRate_ = baudRate; + link_= null; + + inPort_ = new Sim_port("input_buffer"); + super.add_port(inPort_); + + source_PktNum_array = new ArrayList(); + } + + /** + * Sets the Input entities link. This should be used only if the network + * extensions are being used. + * @param link the link to which this Input entity should send data + * @pre link != null + * @post $none + */ + public void addLink(Link link) { + this.link_ = link; + } + + /** + * Gets the baud rate + * @return the baud rate + * @deprecated As of GridSim 2.1, replaced by {@link #getBaudRate()} + * @pre $none + * @post $result >= 0.0 + */ + public double GetBaudRate() { + return this.getBaudRate(); + } + + /** + * Gets the baud rate + * @return the baud rate + * @pre $none + * @post $result >= 0.0 + */ + public double getBaudRate() { + return baudRate_; + } + + /** + * Gets the I/O real number based on a given value + * @param value the specified value + * @return real number + * @deprecated As of GridSim 2.1, replaced by {@link #realIO(double)} + * @pre value >= 0.0 + * @post $result >= 0.0 + */ + public double real_io(double value) { + return this.realIO(value); + } + + /** + * Gets the I/O real number based on a given value + * @param value the specified value + * @return real number + * @pre value >= 0.0 + * @post $result >= 0.0 + */ + public double realIO(double value) { + return GridSimRandom.realIO(value); + } + + /** + * This is an empty method and only applicable to + * {@link gridsim.net.Output} class. + * @param gen a background traffic generator + * @param userName a collection of user entity name (in String object). + * @return <tt>false</tt> since this method is not used by this class. + * @pre gen != null + * @pre userName != null + * @post $none + * @see gridsim.net.Output + */ + public boolean setBackgroundTraffic(TrafficGenerator gen, + Collection userName) + { + return false; + } + + /** + * This is an empty method and only applicable to + * {@link gridsim.net.Output} class. + * @param gen a background traffic generator + * @return <tt>false</tt> since this method is not used by this class. + * @pre gen != null + * @post $none + * @see gridsim.net.Output + */ + public boolean setBackgroundTraffic(TrafficGenerator gen) + { + return false; + } + + /** + * A method that gets one process event at one time until the end + * of a simulation, then delivers an event to the entity (its parent) + * @pre $none + * @post $none + */ + public void body() + { + // Process events + Object obj = null; + while ( Sim_system.running() ) + { + Sim_event ev = new Sim_event(); + super.sim_get_next(ev); // get the next event in the queue + obj = ev.get_data(); // get the incoming data + + // if the simulation finishes then exit the loop + if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { + break; + } + + // if this entity is not connected in a network topology + if (obj != null && obj instanceof IO_data) { + getDataFromEvent(ev); + } + + // if this entity belongs to a network topology + else if (obj != null && link_ != null) { + getDataFromLink(ev); + } + + ev = null; // reset to null for gc to collect + } + } + + /** + * Process incoming event for data without using the network extension + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + private void getDataFromEvent(Sim_event ev) + { + IO_data io = (IO_data) ev.get_data(); + + // if the sender is not part of the overall network topology + // whereas this entity is, then need to return back the data, + // since it is not compatible. + if (link_ != null) + { + // outName = "Output_xxx", where xxx = sender entity name + String outName = GridSim.getEntityName( ev.get_src() ); + + // NOTE: this is a HACK job. "Output_" has 7 chars. So, + // the idea is to get only the entity name by removing + // "Output_" word in the outName string. + String name = outName.substring(7); + + // if the sender is not system GIS then ignore the message + if (GridSim.getEntityId(name) != GridSim.getGridInfoServiceEntityId()) + { + // sends back the data to "Input_xxx", where + // xxx = sender entity name. If not sent, then the sender + // will wait forever to receive this data. As a result, + // the whole simulation program will be hanged or does not + // terminate successfully. + int id = GridSim.getEntityId("Input_" + name); + super.sim_schedule(id, 0.0, ev.get_tag(), io); + + // print an error message + System.out.println(super.get_name() + ".body(): Error - " + + "incompatible message protocol."); + System.out.println(" Sender: " + name + " is not part " + + "of this entity's network topology."); + System.out.println(" Hence, sending back the received data."); + System.out.println(); + return; + } + } + + // NOTE: need to have a try-catch statement. This is because, + // if the above if statement holds, then Input_receiver will send + // back to Input_sender without going through Output_receiver entity. + // Hence, a try-catch is needed to prevent exception of wrong casting. + try + { + // Simulate Transmission Time after Receiving + // Hold first then dispatch + double senderBaudRate = ( (Output) + Sim_system.get_entity(ev.get_src()) ).getBaudRate(); + + // NOTE: io is in byte and baud rate is in bits. 1 byte = 8 bits + // So, convert io into bits + double minBaudRate = Math.min(baudRate_, senderBaudRate); + double communicationDelay = GridSimRandom.realIO( + (io.getByteSize() * BITS) / minBaudRate); + + // NOTE: Below is a deprecated method for SimJava 2 + //super.sim_hold(communicationDelay); + super.sim_process(communicationDelay); // receiving time + } + catch (Exception e) { + // .... empty + } + + // Deliver Event to the entity (its parent) to which + // it is acting as buffer + super.sim_schedule( inPort_, GridSimTags.SCHEDULE_NOW, + ev.get_tag(), io.getData() ); + } + + /** + * Process incoming events from senders that are using the network + * extension + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + private void getDataFromLink(Sim_event ev) + { + Object obj = ev.get_data(); + if (obj instanceof Packet) + { + // decrypt the packet into original format + Packet pkt = (Packet) ev.get_data(); + + /*System.out.println(super.get_name() + ": >>>> FnbInput. PktID: " + + ((FnbNetPacket) pkt).getID() + ". glID: " + + ((FnbNetPacket) pkt).getGlID());*/ + + if (pkt instanceof InfoPacket) + { + processPingRequest( (InfoPacket) pkt); + return; + } + + source_pktNum srcPktNum; + // all except last packet in a data session are null packets + if (pkt instanceof FnbNetPacket) + { + FnbNetPacket np = (FnbNetPacket) pkt; + int tag = np.getTag(); + + // ignore incoming junk packets + if (tag == GridSimTags.JUNK_PKT) { + return; + } + + + // We have to count the gridlet packets arriving at a resource/user, + // so that we make sure all the packets belonging to a gridlet arrive. + // If any of those packets of a gridlet don't arrive, then the gridlet is failed. + // In that case, the router where those packets have been dropped will have told + // the user about the dropping. + String name = super.get_name(); + + + int src_outputPort = ((FnbNetPacket) np).getSrcID(); + //String src_outputPort_str = GridSim.getEntityName(src_outputPort); + + /* + // Uncomment this for more info on the progress of sims + if (name.compareTo("Input_SIM_0_Res_0") == 0) + System.out.println(super.get_name() + + ": packet arrived to the res" + + ". Pkt num: " + + ((FnbNetPacket) np).getPacketNum() + + " from " + src_outputPort_str);*/ + + //int pktID = ((FnbNetPacket) np).getID(); + //int PrevPktNum; // The pkt Num of the previous packet + int pktNum = ((FnbNetPacket) np).getPacketNum(); + int glID = ((FnbNetPacket) np).getGlID(); + srcPktNum = lookForSrcPktNum(src_outputPort, glID); + + if (srcPktNum == null) + { + // Not correct anymore + // Remove form the source_PktNum_array the items whose src is the + // src_outputPort, as those gridlets will be failed (dropped packets) + // removeFromSrcPktNum(src_outputPort); + + // We create a new source_pktNum object only if the packet is the first in this gridlet. + // This means that if the gridlet is failed (as some packets have been dropped), + // no source_pktNum wil be created. + + if (pktNum == 1) + { + srcPktNum = new source_pktNum(src_outputPort, glID); + + source_PktNum_array.add(srcPktNum); + + /*System.out.println(super.get_name() + + ": >>>> FnbInput. First pkt of a gl has just arrived . PktID: " + + ((FnbNetPacket) pkt).getID() + ". glID: " + + ((FnbNetPacket) pkt).getGlID());*/ + + } + }//if (srcPktNum == null) + + if (srcPktNum != null) + { + // If srcPktNum != null this means that the srcPktNum object is correct. + // We have not lost any packet, so the gridlet is ok up to now. + // Hence, update the pktNum in the array. + //srcPktNum.setPktNum(pktNum); + //srcPktNum.setPktID(pktID); + + // Increase the number of pkts already received + //srcPktNum.setNumOfPkts(srcPktNum.getNumOfPkts() + 1); + srcPktNum.increaseNumOfArrivedPkts(); + + // If this is the last packet of the gridlet, then the gridlet is ok + int totalPkt = ((FnbNetPacket) np).getTotalPackets(); + if (srcPktNum.getNumOfPkts() == totalPkt) + srcPktNum.setOk(true); + + + + // ignore incoming null dummy packets + if (tag == GridSimTags.EMPTY_PKT && np.getData() == null) + { + return; + } + else + { + // This is the last packet in the gridlet, so we have to check + // if the previous packets have arrived. + if (srcPktNum.getOk() == true) + { + // The gridlet has arrived perfect, with no packet lost + + // convert the packets into IO_data + Object data = np.getData(); + + + IO_data io = new IO_data(data, np.getSize(), + inPort_.get_dest()); + + // send the data into entity input port + super.sim_schedule(inPort_, + GridSimTags.SCHEDULE_NOW, + tag, + io.getData()); + + /*// REMOVE!!! + System.out.println("\n*********" + super.get_name() + + ": Data (maybe a gridlet) arrived. Pkt num: " + + ((FnbNetPacket) np).getPacketNum() + + " from " + src_outputPort_str + + "\n");*/ + + name = super.get_name(); + if (name.indexOf("Input_SIM_0_Res_5") != -1) + { + fw_write( + "Data (maybe a gridlet) arrived at the Resource\n", + super.get_name()); + + /*System.out.println("\n*********" + + super.get_name() + + ": Data (maybe a gridlet) arrived at the Resource. Pkt num: " + + ((FnbNetPacket) np).getPacketNum() + + " from " + src_outputPort_str + + "\n");*/ + } + + } // if (srcPktNum.getOk() == true) + + } // else of the if (tag == GridSimTags.EMPTY_PKT && np.getData() == null) + + }//if (srcPktNum != null) + + }// if (pkt instanceof FnbNetPacket) + + }// if (obj instanceof Packet) + + } + + /** + * Look for a especific source_pktNum object in the source_PktNum_array + * @param src the source of the packet + * @param pktID the unique id of a packet + * @param glID the id of the girdlet this packet belongs to. + * @return a source_pktNum object whose source is src, null otherwise + * */ + public source_pktNum lookForSrcPktNum(int src, int glID) + { + + source_pktNum srcPktNum; + for (int i = 0; i < source_PktNum_array.size(); i++) + { + srcPktNum = (source_pktNum) source_PktNum_array.get(i); + + if ((srcPktNum.getSource() == src) && (srcPktNum.getGlID() == glID)) + return srcPktNum; + } + + return null; + + } + + /** + * Look for a especific source_pktNum object in the source_PktNum_array + * @param src the source of the packet + * @return a source_pktNum object whose source is src, null otherwise + * */ + public void removeFromSrcPktNum(int src) + { + + source_pktNum srcPktNum; + for (int i = 0; i < source_PktNum_array.size(); i++) + { + srcPktNum = (source_pktNum) source_PktNum_array.get(i); + + if (srcPktNum.getSource() == src) + source_PktNum_array.remove(i); + } + + } + + + + /** + * Prints out the given message into stdout. + * In addition, writes it into a file. + * @param msg a message + * @param file file where we want to write + */ + private static void fw_write(String msg, String file) + { + //System.out.print(msg); + FileWriter fwriter = null; + + try + { + fwriter = new FileWriter(file, true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while opening file " + file); + } + + try + { + fwriter.write(msg); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while writing on file " + file); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while closing file " + file); + } + } + + + /** + * Processes a ping request + * @param pkt a packet for pinging + * @pre pkt != null + * @post $none + */ + private void processPingRequest(InfoPacket pkt) + { + // add more information to ping() packet + pkt.addHop( inPort_.get_dest() ); + pkt.addEntryTime( GridSim.clock() ); + + IO_data io = new IO_data( pkt, pkt.getSize(), inPort_.get_dest() ); + + // send this ping() packet to the entity + super.sim_schedule(inPort_, GridSimTags.SCHEDULE_NOW, + pkt.getTag(), io.getData()); + } + +} // end class + Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetPacket.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetPacket.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,338 @@ + +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + $Id: FnbNetPacket.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + + +package gridsim.net.fnb; + +import gridsim.*; +import gridsim.net.*; + +/** + * Structure of a packet used to encapsulate data passing through the network, + * for the finite network buffers. + * + * In order to reduce the memory consumption, I moved some stuff which is common to all the packets + * of a transmission to another class, called FnbEndToEndPath. + * The stuff I moved is destID, srcID, classtype and totalPkts. + * I also added a FnbEndToEndPath object, which is common for all the packets of a connection + * (of the same gridlet). + * + * + * @invariant $none + * @since GridSim Toolkit 4.1 + * @author Agustin Caminero + */ +public class FnbNetPacket implements Packet +{ + private long size; // packet size (for calculating transmission time) + private Object obj; // the actual object, the type depends on context + + // original tag with which the encapsulated object was submitted + private int tag; + + // the last entity encountered by the object, used to determine direction + private int last; + + private String desc_; // description of this packet + private int pktNum; // packet num in one group + private int pktID_; // a unique packet ID issued by an entity + + private FnbEndToEndPath conn; + + /** + * Constructs a network packet for data that fits into a single network + * packet. + * + * @param data The data to be encapsulated. + * @param pktID The ID of this packet + * @param size The size of the data (in bytes) + * @param tag The original tag which was used with the data, its + * reapplied when the data is extracted from the NetPacket. + * @param srcID The id of the entity where the packet was created. + * @param destID The destination to which the packet has to be sent. + * @pre $none + * @post $none + */ + public FnbNetPacket(Object data, int pktID, long size, int tag, int srcID) + { + this.obj = data ; + this.size = size ; + this.tag = tag ; + + this.last = srcID ; + this.pktID_ = pktID; + + this.pktNum = 1; + + this.desc_ = null; + } + + /** + * This is used to construct a packet that is one in a series. This happens + * when a large piece of data is required to be brokwn down into smaller + * chunks so that they can traverse of links that only support a certain + * MTU. It also allows setting of a classtype so that network schedulers + * maybe provide differntial service to it. + * + * @param data The data to be encapsulated. + * @param pktID The ID of this packet + * @param size The size of the data (in bytes) + * @param tag The original tag which was used with the data, its + * reapplied when the data is extracted from the NetPacket. + * @param srcID The id of the entity where the packet was created. + * @param destID The destination to which the packet has to be sent. + * @param netServiceType the network class type of this packet + * @param pktNum The packet number of this packet in its series. If there + * are 10 packets, they should be numbered from 1 to 10. + * @param totalPkts The total number of packets that the original data was + * split into. This is used by the receiver to confirm that + * all packets have been received. + * @pre $none + * @post $none + */ + public FnbNetPacket(Object data, int pktID, long size, int tag, int srcID, int pktNum) + { + this.obj = data; + this.size = size; + this.tag = tag; + + this.last = srcID; + + this.pktNum = pktNum; + this.pktID_ = pktID; + + this.desc_ = null; + } + + /** + * Returns a description of this packet + * @return a description of this packet + * @pre $none + * @post $none + */ + public String toString() + { + if (desc_ == null) + { + StringBuffer sb = new StringBuffer("Packet #"); + sb.append(pktNum); + sb.append(", out of, "); + sb.append(conn.getTotalPkts()); + sb.append(", with id, "); + sb.append(pktID_); + sb.append(", from, "); + sb.append( GridSim.getEntityName(conn.getSrc()) ); + sb.append(", to, "); + sb.append( GridSim.getEntityName(conn.getDest()) ); + sb.append(", tag, "); + + if (tag == GridSimTags.PKT_FORWARD) { + sb.append("GridSimTags.PKT_FORWARD"); + } + else if (tag == GridSimTags.JUNK_PKT) { + sb.append("GridSimTags.JUNK_PKT"); + } + else { + sb.append(tag); + } + + desc_ = sb.toString(); + } + + return desc_; + } + + /** + * Returns the data encapsulated in this NetPacket + * @return data encapsulated in this packet + * @pre $none + * @post $none + */ + public Object getData() { + return obj; + } + + /** + * Returns the source ID of this packet. The source ID is where the + * NetPacket was originally created. + * + * @return the source id. + * @pre $none + * @post $none + */ + public int getSrcID() { + return conn.getSrc(); + } + + /** + * Returns the ID of this packet + * @return packet ID + * @pre $none + * @post $none + */ + public int getID() { + return pktID_; + } + + /** + * Modifies the data encapsulated in this NetPacket. + * @param data the packet's data + * @pre $none + * @post $none + */ + public void setData(Object data) { + this.obj = data; + } + + /** + * Gets the size of this packet + * @return the packet size + * @pre $none + * @post $none + */ + public long getSize() { + return size; + } + + /** + * Sets the packet size + * @param size the packet size + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre size >= 0 + * @post $none + */ + public boolean setSize(long size) + { + if (size < 0) { + return false; + } + + this.size = size; + return true; + } + + /** + * Returns the tag associated originally with data that was encapsulated in + * this packet. + * + * @return the tag of the data contained. + * @pre $none + * @post $none + */ + public int getTag() { + return tag; + } + + /** + * Returns the destination ID of this packet + * + * @return destination ID + * @pre $none + * @post $none + */ + public int getDestID() { + return conn.getDest(); + } + + /** + * Sets the destination id of this packet + * @param id the destination id + * @pre id >= 0 + * @post $none + */ + public void setDestID(int id) { + //this.destID = id; + } + + /** + * Sets the last hop that this NetPacket traversed. This is used to + * determine the next hop at routers. Only routers and hosts/GridResources + * set this, links do not modify it. + * @param last the entity ID from the last hop + * @pre last >= 0 + * @post $none + */ + public void setLast(int last) { + this.last = last; + } + + /** + * Returns the ID of the last hop that this packet traversed. This could be + * the ID of a router, host or GridResource. + * + * @return ID of the last hop + * @pre $none + * @post $none + */ + public int getLast() { + return last; + } + + /** + * Sets the network class type of this packet, so that it can receive + * differentiated services. + * @param netServiceType a network service type + * @pre netServiceType >= 0 + * @post $none + */ + public void setNetServiceType(int netServiceType) { + conn.setClasstype(netServiceType); + } + + /** + * Returns the class type of this packet. Used by routers etc. to determine + * the level of service that this packet should obtain. + * + * @return the class of this packet + * @pre $none + * @post $none + */ + public int getNetServiceType() { + return conn.getClasstype(); + } + + /** + * Returns the serial number of this packet. + * + * @return packet number + * @pre $none + * @post $none + */ + public int getPacketNum() { + return pktNum; + } + + /** + * Returns the total number of packets in this stream. A stream of + * packets is sent whenever the data is too big to be sent as one + * packet. + * + * @return total number of packets in this stream. + * @pre $none + * @post $none + */ + public int getTotalPackets() { + return conn.getTotalPkts(); + } + + /** Establishes the end to end path to another entity */ + public void setPath(FnbEndToEndPath c) + { + conn = c; + } + + /**Returns the gridlet to which this packet belongs*/ + public int getGlID() + { + return conn.getGlID(); + } + +} // end class + Added: branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetworkReader.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetworkReader.java (rev 0) +++ branches/gridsim4.0-branch2/source/gridsim/net/fnb/FnbNetworkReader.java 2008-05-29 16:44:20 UTC (rev 178) @@ -0,0 +1,352 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and distributed Systems such as Lcusters and Grids + * License: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: FnbNetworkReader.java,v 1.13 2008/05/09 05:56:31 agustin Exp $ + */ + +package gridsim.net.fnb; + +import gridsim.net.fnb.*; +import gridsim.net.*; +import java.util.*; +import java.io.*; +import gridsim.*; + +/** + * This is an utility class, which parses a file and constructs the + * network topology auto... [truncated message content] |
From: <aca...@us...> - 2008-05-29 16:42:44
|
Revision: 177 http://gridsim.svn.sourceforge.net/gridsim/?rev=177&view=rev Author: acaminero Date: 2008-05-29 09:42:45 -0700 (Thu, 29 May 2008) Log Message: ----------- incorporated FNB I/O ports Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-05-29 16:40:25 UTC (rev 176) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-05-29 16:42:45 UTC (rev 177) @@ -14,6 +14,7 @@ import gridsim.net.flow.*; import gridsim.util.*; import java.util.Collection; +import gridsim.net.fnb.*; /** @@ -166,7 +167,6 @@ * * @author Manzur Murshed and Rajkumar Buyya * @author Anthony Sulistio (re-written this class) - * @author James Broberg (added FlowInput and FlowOutput) * @since GridSim Toolkit 3.0 * @see eduni.simjava.Sim_entity * @see gridsim.net.Output @@ -177,7 +177,7 @@ */ public class GridSimCore extends Sim_entity { - private boolean networkedFlag_; // true, if networked entity, other false + private boolean networkedFlag_; // true, if networked entity, other false // false means NOT invoked private boolean terminateIOEntitiesFlag_ = false; @@ -191,11 +191,11 @@ /** Sending data via output port to external entities */ protected Sim_port output; - + // Output port but only for a network extension. private NetIO out_ = null; - // TODO: new addition + /** Specifies which type of network to be used */ protected static int NETWORK_TYPE = GridSimTags.NET_PACKET_LEVEL; @@ -313,27 +313,30 @@ // Packet Level networking has input & output if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_PACKET_LEVEL) { - in = new Input("Input_" + name, baudRate); + in = new Input("Input_" + name, baudRate); out_ = new Output("Output_" + name, baudRate); } // Flow Level networking has flow input & output else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { - in = new FlowInput("Input_" + name, baudRate); - out_ = new FlowOutput("Output_" + name, baudRate); + in = new FlowInput("Input_" + name, baudRate); + out_ = new FlowOutput("Output_" + name, baudRate); } - else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_BUFFER_PACKET_LEVEL) + // Use Finite network buffer + else if (GridSimCore.NETWORK_TYPE == + GridSimTags.NET_BUFFER_PACKET_LEVEL) { - // TODO: + in = new FnbInput("Input_" + name, baudRate); + out_ = new FnbOutput("Output_" + name, baudRate); } - + System.out.println(super.get_name() + ".initNetwork()"); Sim_system.link_ports(name, "input", "Input_" + name, "input_buffer"); Sim_system.link_ports(name, "output", "Output_" + name, "output_buffer"); if (link != null) { - in.addLink(link); - out_.addLink(link); + in.addLink(link); + out_.addLink(link); } } @@ -347,7 +350,8 @@ * @pre $none * @post $none */ - public Link getLink() { + public Link getLink() + { return link_; } @@ -394,6 +398,7 @@ return out_.setBackgroundTraffic(gen, userName); } + /** * Pings to a particular entity ID with a given packet size. * <p> @@ -409,7 +414,8 @@ * @pre size >= 0 * @post $none */ - protected boolean ping(int entityID, int size) { + protected boolean ping(int entityID, int size) + { return ping(entityID, size, 0.0, 0); } @@ -428,7 +434,8 @@ * @pre size >= 0 * @post $none */ - protected boolean ping(String entityName, int size) { + protected boolean ping(String entityName, int size) + { return ping(entityName, size, 0.0, 0); } @@ -454,7 +461,7 @@ * @post $none */ protected boolean ping(String entityName, int size, double delay, - int netServiceLevel) + int netServiceLevel) { int id = GridSim.getEntityId(entityName); return ping(id, size, delay, netServiceLevel); @@ -487,24 +494,25 @@ if (entityID < 0) { System.out.println(super.get_name() + ".ping(): Error - " + - "invalid entity ID or name."); + "invalid entity ID or name."); return false; } if (size < 0) { System.out.println(super.get_name() + ".ping(): Error - " + - "invalid packet size."); + "invalid packet size."); return false; } - if (delay < 0) { + if (delay < 0) + { delay = 0.0; } // send this ping to the destination - send( this.output, delay, GridSimTags.INFOPKT_SUBMIT, - new IO_data(null, size, entityID, netServiceLevel) ); + send(this.output, delay, GridSimTags.INFOPKT_SUBMIT, + new IO_data(null, size, entityID, netServiceLevel)); return true; } @@ -533,7 +541,8 @@ int netServiceLevel) { boolean result = ping(entityID, size, delay, netServiceLevel); - if (result == false) { + if (result == false) + { return null; } @@ -624,21 +633,20 @@ super.sim_get_next(tag, ev); InfoPacket pkt = null; - try { + try + { pkt = (InfoPacket) ev.get_data(); - } - catch(Sim_exception sim) + } catch (Sim_exception sim) { System.out.print(super.get_name() + ".getPingResult(): Error - "); System.out.println("exception occurs. See the below message:"); - System.out.println( sim.getMessage() ); + System.out.println(sim.getMessage()); pkt = null; - } - catch(Exception e) + } catch (Exception e) { System.out.print(super.get_name() + ".getPingResult(): Error - "); System.out.println("exception occurs. See the below message:"); - System.out.println( e.getMessage() ); + System.out.println(e.getMessage()); pkt = null; } @@ -657,7 +665,8 @@ * @pre $none * @post $none */ - protected void TerminateInputOutputEntities() { + protected void TerminateInputOutputEntities() + { terminateIOEntities(); } @@ -675,7 +684,7 @@ protected void terminateIOEntities() { // If it is Networked entity and Not yet terminated, then terminate. - if ( isNetworked() && !terminateIOEntitiesFlag_ ) + if (isNetworked() && !terminateIOEntitiesFlag_) { // Send END_OF_SIMULATION to Input entity send(input, 0.0, GridSimTags.END_OF_SIMULATION); @@ -696,7 +705,8 @@ * @pre $none * @post $none */ - protected void finalize() { + protected void finalize() + { finalizeGridSimulation(); } @@ -707,7 +717,8 @@ * @pre $none * @post $none */ - protected void finalizeGridSimulation() { + protected void finalizeGridSimulation() + { terminateIOEntities(); } @@ -719,7 +730,8 @@ * @pre $none * @post $result == true || false */ - protected boolean IsNetworked() { + protected boolean IsNetworked() + { return isNetworked(); } @@ -730,7 +742,8 @@ * @pre $none * @post $result == true || false */ - protected boolean isNetworked() { + protected boolean isNetworked() + { return networkedFlag_; } @@ -777,7 +790,8 @@ * @pre delay >= 0.0 * @post $none */ - protected void Send(String entityName, double delay, int gridSimTag) { + protected void Send(String entityName, double delay, int gridSimTag) + { send(entityName, delay, gridSimTag); } @@ -823,12 +837,14 @@ */ protected void send(String entityName, double delay, int gridSimTag) { - if (entityName == null) { + if (entityName == null) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } @@ -836,7 +852,7 @@ if (id < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity name \"" + entityName + "\"."); + "invalid entity name \"" + entityName + "\"."); return; } @@ -938,12 +954,14 @@ protected void send(String entityName, double delay, int gridSimTag, Object data) { - if (entityName == null) { + if (entityName == null) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } @@ -951,7 +969,7 @@ if (id < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity name \"" + entityName + "\"."); + "invalid entity name \"" + entityName + "\"."); return; } @@ -1000,7 +1018,8 @@ * @pre delay >= 0.0 * @post $none */ - protected void Send(int entityID, double delay, int gridSimTag) { + protected void Send(int entityID, double delay, int gridSimTag) + { send(entityID, delay, gridSimTag); } @@ -1046,19 +1065,21 @@ */ protected void send(int entityID, double delay, int gridSimTag) { - if (entityID < 0) { + if (entityID < 0) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } if (entityID < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity id " + entityID); + "invalid entity id " + entityID); return; } @@ -1158,19 +1179,21 @@ */ protected void send(int entityID, double delay, int gridSimTag, Object data) { - if (entityID < 0) { + if (entityID < 0) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } if (entityID < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity id " + entityID); + "invalid entity id " + entityID); return; } @@ -1219,7 +1242,8 @@ * @pre delay >= 0.0 * @post $none */ - protected void Send(Sim_port destPort, double delay, int gridSimTag) { + protected void Send(Sim_port destPort, double delay, int gridSimTag) + { send(destPort, delay, gridSimTag); } @@ -1268,12 +1292,13 @@ if (destPort == null) { System.out.println(super.get_name() + ".send(): Error - " + - "destination port is null or empty."); + "destination port is null or empty."); return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } @@ -1326,7 +1351,7 @@ * @see gridsim.IO_data */ protected void Send(Sim_port destPort, double delay, int gridSimTag, - Object data) + Object data) { send(destPort, delay, gridSimTag, data); } @@ -1375,22 +1400,32 @@ * @see gridsim.IO_data */ protected void send(Sim_port destPort, double delay, int gridSimTag, - Object data) + Object data) { if (destPort == null) { System.out.println(super.get_name() + ".send(): Error - " + - "destination port is null or empty."); + "destination port is null or empty."); return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } super.sim_schedule(destPort, delay, gridSimTag, data); } + /**This function returns the NETWORK_TYPE parameter. + * @return NETWORK_TYPE + * */ + public static int getNetworkType() + { + return NETWORK_TYPE; + } + + } // end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aca...@us...> - 2008-05-29 16:41:31
|
Revision: 176 http://gridsim.svn.sourceforge.net/gridsim/?rev=176&view=rev Author: acaminero Date: 2008-05-29 09:40:25 -0700 (Thu, 29 May 2008) Log Message: ----------- added new tags for the gridsim.net.fnb package?\195?\167 Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java 2008-05-27 07:55:44 UTC (rev 175) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java 2008-05-29 16:40:25 UTC (rev 176) @@ -32,30 +32,30 @@ private static final int ARBASE = 200; public static final int NET_PACKET_LEVEL = NETBASE + 11; - + public static final int NET_FLOW_LEVEL = NETBASE + 12; - + // Denotes flow en-route to destination (used manually by entities) - public static final int FLOW_SUBMIT = NETBASE + 13; - + public static final int FLOW_SUBMIT = NETBASE + 13; + // Internal message to check forecast of flow duration public static final int FLOW_HOLD = NETBASE + 14; - + // Message to update forecast of flow duration public static final int FLOW_UPDATE = NETBASE + 15; - + // Denotes flow ack en-route to destination (used manually by entities) public static final int FLOW_ACK = NETBASE + 16; - + // identify a flow as a junk flow used for background traffic - // public static final int JUNK_FLOW = NETBASE + 17; - + // public static final int JUNK_FLOW = NETBASE + 17; + public static final int NET_BUFFER_PACKET_LEVEL = NETBASE + 18; - + // TODO: different flow sharing models - not sure if I will need these // INV-LAT flows are weighted proportionally to the bottleneck latency // public static final int NET_FLOW_LEVEL_INV_LAT = NETBASE + x; - // INV-LAT-BOUND flows are weighted proportionally to the bottleneck latency + // INV-LAT-BOUND flows are weighted proportionally to the bottleneck latency // with bounded bandwidth availability // INV-RTT flows are weighted proportionally to the bottleneck RTT // public static final int NET_FLOW_LEVEL_INV_RTT = NETBASE + x; @@ -64,7 +64,7 @@ // public static final int NET_FLOW_LEVEL_INV_RTT_BOUND = NETBASE + x; // MAX-MIN flows are equally weighted so all flows get equal share // public static final int NET_FLOW_LEVEL_MAX_MIN = NETBASE + x; - + ////////////////////////////////////////////////////////////////////// /** Denotes boolean <tt>true</tt> in <tt>int</tt> value */ @@ -206,8 +206,8 @@ * {@link gridsim.net.Output} entities. */ public static final int EMPTY_PKT = NETBASE + 8; - + /** Denotes that this packet will be sent to a packet scheduler by a router * for enqueing. * This tag is used by a router to an active packet scheduler, such as @@ -273,9 +273,73 @@ */ public static final int GRIDLET_MOVE_ACK = BASE + 30; + /////////////////////////////////////////////////////////////// + // For the gridsim.net.fnb package + /**This is to simulate the finite buffers. This constant is to tell an entity + * that a packet has been dropped*/ + public static final int FNB_PACKET_DROPPED = BASE + 31; + + + /**This is to simulate the finite buffers. This constant is used when an Output + * port tells a user that a gridlet has failed because at least of his packets + * has been dropped*/ + public static final int FNB_GRIDLET_FAILED_BECAUSE_PACKET_DROPPED = BASE + 32; + + /**This is to simulate the finite buffers. A FIFO dropping algorithm*/ + public static final int FNB_FIFO = BASE + 33; + + /**This is to simulate the finite buffers. A RED (Random Early Detection) dropping algorithm*/ + public static final int FNB_RED = BASE + 34; + + /**This is to simulate the finite buffers. The event used to capture the number + * of dropped pkts. This event is sent form a SCFScheduler to itself every T time*/ + public static final int FNB_COUNT_DROPPED_PKTS = BASE + 35; + + /**This is to simulate the finite buffers. Adaptative RED (Random Early Detection) dropping algorithm*/ + public static final int FNB_ARED = BASE + 36; + + /**This is to update the parameters of ARED*/ + public static final int FNB_UPDATE_ARED_PARAMETERS = BASE + 37; + + /**This is to update the parameters of ARED. The time period between updates (0.5 seconds)*/ + public static final double FNB_UPDATE_ARED_PARAMETERS_PERIOD = 0.5; + + /** + * When a router drops a packet, it has to tell to user, so that he does not get jammed. + * But it does not do it immediately (when the dropping ocurs) but with a given delay (this delay).*/ + public static final double FNB_DROPPING_DELAY = 0.01; // 10 milliseconds + /////////////////////////////////////////////////////////////// + /** + * This is to simulate resource failure. The RegioalGIS will send this event + * to itself, so that it can decide which time the event is sent. Also, The RegionalGIS + * will send this event to the GridResource to make it "fail" for a period of time. + * This tag is also used when a failed resource receives a ping request. + * In this case, the resource will use this tag in the ping response */ + public static final int GRIDRESOURCE_FAILURE = 10000 + 31; + + /** + * This is used when a resource which has failed comes back to life. */ + public static final int GRIDRESOURCE_RECOVERY = 10000 + 32; + + /** + * This is used when the user polls the resource to find out if they are out of order. */ + public static final int GRIDRESOURCE_FAILURE_INFO = 10000 + 33; + + /** + * This is used when the user polls the resources . */ + public static final int GRIDRESOURCE_POLLING = 10000 + 34; + + /** The polling interval for users*/ + public static final int POLLING_TIME_USER = 100; // 5; + + /** The polling interval for the GISs entities*/ + public static final int POLLING_TIME_GIS = 2000; //10; + + /////////////////////////////////////////////////////////////// + // The below tags are sent by AdvanceReservation to ARGridResource class /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-05-27 07:55:38
|
Revision: 175 http://gridsim.svn.sourceforge.net/gridsim/?rev=175&view=rev Author: marcos_dias Date: 2008-05-27 00:55:44 -0700 (Tue, 27 May 2008) Log Message: ----------- This update includes and example on how to use the continuous double auction. It also allows the user to change the id of an auction. Modified Paths: -------------- trunk/source/gridsim/auction/Auction.java Added Paths: ----------- trunk/examples/Auction/AuctionEx03/ trunk/examples/Auction/AuctionEx03/AuctionResource.java trunk/examples/Auction/AuctionEx03/Broker.java trunk/examples/Auction/AuctionEx03/ExampleAuction.java trunk/examples/Auction/AuctionEx03/NetUser.java trunk/examples/Auction/AuctionEx03/README.txt trunk/examples/Auction/AuctionEx03/ResponderImpl.java trunk/examples/Auction/AuctionEx03/output.txt Added: trunk/examples/Auction/AuctionEx03/AuctionResource.java =================================================================== --- trunk/examples/Auction/AuctionEx03/AuctionResource.java (rev 0) +++ trunk/examples/Auction/AuctionEx03/AuctionResource.java 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,182 @@ +/* + * Author: Marcos Dias de Assuncao + * Date: May 2008 + * Description: A simple program to demonstrate of how to use GridSim + * auction extension package. + * This example shows how to create user, resource, auctioneer + * and auction entities connected via a network topology, + * using link and router. + * + */ + +import eduni.simjava.Sim_event; +import eduni.simjava.distributions.ContinuousGenerator; +import eduni.simjava.distributions.Sim_uniform_obj; +import gridsim.AllocPolicy; +import gridsim.GridResource; +import gridsim.GridSimTags; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.auction.AuctionObserver; +import gridsim.auction.AuctionTags; +import gridsim.auction.MessageAsk; +import gridsim.auction.Responder; +import gridsim.net.Link; + +import java.util.Calendar; + +/** + * This class implements a resource that has an observer for an auction + * + * @author Marcos Dias de Assuncao + */ +public class AuctionResource extends GridResource { + private AuctionObserver observer; + private ContinuousGenerator priceGenerator; + private int secondsBetweenAsks = 60; + private int auctioneerId = -1; + + // a tag ID to be used to schedule an event to this entity to create an ask + private static final int CREATE_ASK_TAG = 7001; + + /** + * Allocates a new GridResource object. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param baud_rate network communication or bandwidth speed + * @param resource an object of ResourceCharacteristics + * @param calendar an object of ResourceCalendar + * @param policy a scheduling policy for this Grid resource. If no + * scheduling policy is defined, the default one is + * <tt>SpaceShared</tt> + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResource must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridResource#GridResource(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicy) + */ + public AuctionResource(String name, double baud_rate, + ResourceCharacteristics resource, + ResourceCalendar calendar, + AllocPolicy policy) throws Exception{ + + super(name,baud_rate,resource,calendar,policy); + + Responder responder = new ResponderImpl(resource,calendar,policy); + observer = new AuctionObserver(this.get_id(),"Observer_1",this.output,responder); + } + + /** + * Allocates a new GridResource object. When making a different type of + * GridResource object, use this constructor and then overrides + * {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param link the link that will be used to connect this + * GridResource to another Entity or Router. + * @param resource an object of ResourceCharacteristics + * @param calendar an object of ResourceCalendar + * @param policy a scheduling policy for this Grid resource. If no + * scheduling policy is defined, the default one is + * <tt>SpaceShared</tt> + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResource must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @see gridsim.AllocPolicy + * @pre name != null + * @pre link != null + * @pre resource != null + * @pre calendar != null + * @pre policy != null + * @post $none + */ + public AuctionResource(String name, Link link, + ResourceCharacteristics resource, + ResourceCalendar calendar, + AllocPolicy policy) throws Exception{ + + super(name,link,resource,calendar,policy); + + Responder responder = new ResponderImpl(resource,calendar,policy); + observer = new AuctionObserver(this.get_id(),"Observer_1",this.output,responder); + } + + /** + * Returns the auction observer for this resource + * @param observer + * @return the observer for this resource + */ + public boolean setAuctionObserver(AuctionObserver observer){ + if(observer == null) + return false; + + this.observer = observer; + return true; + } + + /** + * Defines the behaviour of this entity + */ + public void body() { + // creates a uniform distribution to create prices between $1 and $2 + long seed = 11L*13*17*19*23+1; + priceGenerator = new Sim_uniform_obj("priceGen", 1, 2, seed); + super.sim_schedule(super.get_id(), secondsBetweenAsks, CREATE_ASK_TAG); + super.body(); + } + + /** + * Since we are implementing other resource, this method has to be + * implemented in order to make resource able to deal with other kind + * of events. + * This method is called by {@link #body()} for incoming unknown tags. + * + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + protected void processOtherEvent(Sim_event ev){ + if(ev.get_tag() == CREATE_ASK_TAG) { + createAsk(); + super.sim_schedule(super.get_id(), secondsBetweenAsks, CREATE_ASK_TAG); + } + else { + observer.processEvent(ev); + } + } + + /** + * Sets the ID of the auctioneer to whom this resource will send asks + * @param id the auctioneer's ID + */ + public void setAuctioneerID(int id) { + auctioneerId = id; + } + + /* + * Creates an ask and sends it to the auctioneer + */ + private void createAsk() { + float price = (float)priceGenerator.sample(); + MessageAsk ask = new MessageAsk(0, AuctionTags.CONTINUOUS_DOUBLE_AUCTION, price); + ask.setSourceID(super.get_id()); + super.send(auctioneerId, GridSimTags.SCHEDULE_NOW, AuctionTags.AUCTION_ASK, ask); + } +} \ No newline at end of file Added: trunk/examples/Auction/AuctionEx03/Broker.java =================================================================== --- trunk/examples/Auction/AuctionEx03/Broker.java (rev 0) +++ trunk/examples/Auction/AuctionEx03/Broker.java 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,122 @@ +/* + * Author: Marcos Dias de Assuncao + * Date: May 2008 + * Description: A simple program to demonstrate of how to use GridSim + * auction extension package. + * This example shows how to create user, resource, auctioneer + * and auction entities connected via a network topology, + * using link and router. + */ + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_port; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.auction.Auction; +import gridsim.auction.Auctioneer; +import gridsim.auction.ContinuousDoubleAuction; +import gridsim.auction.MessageAsk; +import gridsim.auction.MessageBid; +import gridsim.net.SimpleLink; + +/** + * This class implements a broker for the user. The broker bids containing jobs + * from the users, behaves as an auctioneer, creates a double auction, and submits + * jobs after a match of ask and bid is found. + * + * @author Marcos Dias de Assuncao + */ +public class Broker extends Auctioneer { + private ContinuousDoubleAuction auction = null; + private int numUsers; + private int finishedUsers = 0; + protected static final int FINISHED_EXPERIMENTS = 7002; + + /** + * Constructor + * @param name a name for the broker + * @param baud_rate the baud rate of the link to which the broker is attached + * @param delay the delay of the link + * @param MTU the maximum transfer unit of the link + * @throws Exception + * @see gridsim.auction.Auctioneer + * @see gridsim.GridSim + */ + public Broker(String name, double baud_rate, double delay, + int MTU, int numUsers) throws Exception{ + super( name, new SimpleLink(name+"_link",baud_rate,delay, MTU) ); + this.numUsers = numUsers; + } + + /** + * Returns the output port of the broker + * @return a port which corresponds to the output port of the entity + */ + public Sim_port getOutputPort(){ + return this.output; + } + + /** + * This method is called when an auction is finished + * @see gridsim.auction.Auctioneer#onAuctionClose(gridsim.auction.Auction) + */ + public synchronized void onAuctionClose(Auction auction){ + return; + } + + /** + * This method is called when a match for a double auction is found. + * OBS: We don't use double auctions in this example + * @see gridsim.auction.Auctioneer#onResponseToAsk(gridsim.auction.MessageAsk, gridsim.auction.MessageBid, double) + */ + public synchronized void onResponseToAsk(MessageAsk ask, MessageBid bid, double price){ + Gridlet job = (Gridlet)bid.getAttribute("job"); + + System.out.println("\nA MATCH of an ASK with a BID has been performed:" + + "\nBID details:" + + "\nSender's ID: " + bid.getSourceID() + + "\nPrice offered for executing the job: " + bid.getPrice() + + "\nASK details:" + + "\nSender's ID: " + ask.getSourceID() + + "\nPrice asked for executing the job: " + ask.getPrice() + + "\nPrice given by the auctioneer: " + price); + + gridletSubmit(job, ask.getSourceID()); + } + + public void body() { + try { + // waits 10 second to start the auction + super.gridSimHold(10.0); + + auction = + new ContinuousDoubleAuction(super.get_name() + "_CDA", super.get_id(), + Double.MAX_VALUE, this.output); + + System.out.println("Creating Auction " + auction.getAuctionID()); + + // add the auction + super.addAuction(auction); + + // start the auction + super.startAuction(auction.getAuctionID()); + + } catch (Exception e) { + e.printStackTrace(); + } + + super.body(); + } + + public void processOtherEvent(Sim_event ev) { + + if(ev.get_tag() == Broker.FINISHED_EXPERIMENTS) { + finishedUsers++; + } + + if(finishedUsers >= numUsers) { + super.send(auction.get_id(), GridSimTags.SCHEDULE_NOW, GridSimTags.END_OF_SIMULATION); + super.send(super.get_id(), 0, GridSimTags.END_OF_SIMULATION); + } + } +} Added: trunk/examples/Auction/AuctionEx03/ExampleAuction.java =================================================================== --- trunk/examples/Auction/AuctionEx03/ExampleAuction.java (rev 0) +++ trunk/examples/Auction/AuctionEx03/ExampleAuction.java 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,304 @@ +/* + * Author: Marcos Dias de Assuncao + * Date: May 2008 + * Description: A simple program to demonstrate of how to use GridSim + * auction extension package. + * This example shows how to create user, resource, auctioneer + * and auction entities connected via a network topology, + * using link and router. + * + */ + +import eduni.simjava.distributions.Sim_uniform_obj; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.PE; +import gridsim.PEList; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.net.FIFOScheduler; +import gridsim.net.Link; +import gridsim.net.RIPRouter; +import gridsim.net.Router; +import gridsim.net.SimpleLink; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; + +/** + * This class creates resources, users and routers and links them + * in a network topology. This examples uses a continuous double auction. + * + * @author Marcos Dias de Assuncao + */ +public class ExampleAuction { + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * <p> + * In this simple example, we are simulating one Grid resource with three + * Machines that contains one or more PEs. + * @param name a Grid Resource name + * @param baud_rate the bandwidth of this entity + * @param delay the propagation delay + * @param MTU Maximum Transmission Unit + * @param cost the cost of using this resource + * @param mips Capability of a CPU in MIPS + * @return a GridResource object + */ + private static GridResource createGridResource(String name, + double baud_rate, double delay, int MTU, + double cost, int mips, int auctioneerId) + { + System.out.println(); + System.out.println("Starting to create one Grid resource with " + + "3 Machines"); + + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + //System.out.println("Creates a Machine list"); + + + // 2. A Machine contains one or more PEs or CPUs. Therefore, should + // create an object of PEList to store these PEs before creating + // a Machine. + PEList peList1 = new PEList(); + //System.out.println("Creates a PE list for the 1st Machine"); + + + // 3. Create PEs and add these into an object of PEList. + // In this example, we are using a resource from + // hpc420.hpcc.jp, AIST, Tokyo, Japan + // Note: these data are taken the from GridSim paper, page 25. + // In this example, all PEs has the same MIPS (Millions + // Instruction Per Second) Rating for a Machine. + peList1.add( new PE(0, mips) ); // need to store PE id and MIPS Rating + peList1.add( new PE(1, mips) ); + peList1.add( new PE(2, mips) ); + peList1.add( new PE(3, mips) ); + //System.out.println("Creates 4 PEs with same MIPS Rating and put them"+ + // " into the PE list"); + + + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(0, peList1) ); // First Machine + //System.out.println("Creates the 1st Machine that has 4 PEs and " + + // "stores it into the Machine list"); + //System.out.println(); + + // 5. Repeat the process from 2 if we want to create more Machines + // In this example, the AIST in Japan has 3 Machines with same + // MIPS Rating but different PEs. + // NOTE: if you only want to create one Machine for one Grid resource, + // then you could skip this step. + PEList peList2 = new PEList(); + //System.out.println("Creates a PE list for the 2nd Machine"); + + peList2.add( new PE(0, mips) ); + peList2.add( new PE(1, mips) ); + peList2.add( new PE(2, mips) ); + peList2.add( new PE(3, mips) ); + //System.out.println("Creates 4 PEs with same MIPS Rating and put them"+ + // " into the PE list"); + + mList.add( new Machine(1, peList2) ); // Second Machine + //System.out.println("Creates the 2nd Machine that has 4 PEs and " + + // "stores it into the Machine list"); + //System.out.println(); + + PEList peList3 = new PEList(); + //System.out.println("Creates a PE list for the 3rd Machine"); + + peList3.add( new PE(0, mips) ); + peList3.add( new PE(1, mips) ); + //System.out.println("Creates 2 PEs with same MIPS Rating and put them"+ + // " into the PE list"); + + mList.add( new Machine(2, peList3) ); // Third Machine + //System.out.println("Creates the 3rd Machine that has 2 PEs and " + + // "stores it into the Machine list"); + //System.out.println(); + + // 6. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 9.0; // time zone this resource located + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, ResourceCharacteristics.TIME_SHARED, + time_zone, cost); + + //System.out.println("Creates the properties of a Grid resource and " + + // "stores the Machine list"); + + // 7. Finally, we need to create a GridResource object. + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + + ResourceCalendar calendar = new ResourceCalendar(time_zone, peakLoad, + offPeakLoad, holidayLoad, weekends, holidays, seed); + + AuctionResource gridRes = null; + try + { + // creates a GridResource with a link + gridRes = new AuctionResource(name, + new SimpleLink(name + "_link", baud_rate, delay, MTU), + resConfig,calendar, null); + + gridRes.setAuctioneerID(auctioneerId); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Finally, creates one Grid resource (name: " + name + + " - id: " + gridRes.get_id() + ")"); + + System.out.println(); + return gridRes; + } + + /** + * + * @param args + */ + public static void main(String[] args) { + try{ + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = true; // mean trace GridSim events + int num_user = 3; + int num_resource = 2; + int num_gridlet = 3; + + // First step: Initialize the GridSim package. It should be called + // before creating any entities. We can't run GridResource + // entity without initializing GridSim first. We will get run-time + // exception error. + + // Initialize the GridSim package + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + double baud_rate = 1000; // bits/sec + double propDelay = 10; // propagation delay in millisecond + int mtu = 1500; // max. transmission unit in byte + + long seed = 11L*13*17*19*23+1; + + Sim_uniform_obj genCost = new Sim_uniform_obj("cost",1,2, seed); + Sim_uniform_obj genMIPS = new Sim_uniform_obj("mips",300,400, seed); + + + Broker broker = new Broker("Broker", baud_rate, propDelay, mtu, num_user); + + // more resources can be created by + // setting num_resource to an appropriate value + ArrayList resList = new ArrayList(num_resource); + for (int i = 0; i < num_resource; i++) { + GridResource res = createGridResource("Resource_"+i, baud_rate, + propDelay, mtu, genCost.sample(), + ((int)genMIPS.sample()), broker.get_id()); + // add a resource into a list + resList.add(res); + } + + // create users + ArrayList userList = new ArrayList(num_user); + for (int i = 0; i < num_user; i++) + { + NetUser user = new NetUser("User_" + i, num_gridlet, + baud_rate, propDelay, mtu, broker); + + // add a user into a list + userList.add(user); + } + + ////////////////////////////////////////// + // Fourth step: Builds the network topology among entities. + + // In this example, the topology is: + // user(s) --1Mb/s-- r1 --10Mb/s-- r2 --1Mb/s-- GridResource(s) + + // create the routers. + // If trace_flag is set to "true", then this experiment will create + // the following files (apart from sim_trace and sim_report): + // - router1_report.csv + // - router2_report.csv + Router r1 = new RIPRouter("router1", trace_flag); // router 1 + Router r2 = new RIPRouter("router2", trace_flag); // router 2 + + FIFOScheduler brokerSched = new FIFOScheduler("NetBrokerSched"); + r1.attachHost(broker, brokerSched); + + // connect all user entities with r1 with 1Mb/s connection + // For each host, specify which PacketScheduler entity to use. + NetUser user = null; + for (int i = 0; i < userList.size(); i++) + { + // A First In First Out Scheduler is being used here. + // SCFQScheduler can be used for more fairness + FIFOScheduler userSched = new FIFOScheduler("NetUserSched_"+i); + user = (NetUser) userList.get(i); + r1.attachHost(user, userSched); + } + + // connect all resource entities with r2 with 1Mb/s connection + + // For each host, specify which PacketScheduler entity to use. + GridResource resObj = null; + for (int i = 0; i < resList.size(); i++) + { + FIFOScheduler resSched = new FIFOScheduler("GridResSched_"+i); + resObj = (GridResource) resList.get(i); + r2.attachHost(resObj, resSched); + } + + // then connect r1 to r2 with 10Mb/s connection + // For each host, specify which PacketScheduler entity to use. + baud_rate = 10000; + Link link = new SimpleLink("r1_r2_link", baud_rate, propDelay, mtu); + FIFOScheduler r1Sched = new FIFOScheduler("r1_Sched"); + FIFOScheduler r2Sched = new FIFOScheduler("r2_Sched"); + + // attach r2 to r1 + r1.attachRouter(r2, link, r1Sched, r2Sched); + + ////////////////////////////////////////// + // Starts the simulation + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + +// // also prints the routing table +// r1.printRoutingTable(); +// r2.printRoutingTable(); + } + catch(Exception ex){ + System.out.println(" Error executing simulation. Message: " + ex.getMessage()); + ex.printStackTrace(); + } + } + +} Added: trunk/examples/Auction/AuctionEx03/NetUser.java =================================================================== --- trunk/examples/Auction/AuctionEx03/NetUser.java (rev 0) +++ trunk/examples/Auction/AuctionEx03/NetUser.java 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,164 @@ +/* + * Author: Marcos Dias de Assuncao + * Date: May 2008 + * Description: A simple program to demonstrate of how to use GridSim + * auction extension package. + * This example shows how to create user, resource, auctioneer + * and auction entities connected via a network topology, + * using link and router. + * + * This class was adapted from examples on network + * package developed by: Anthony Sulistio + * + */ + + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; +import eduni.simjava.distributions.ContinuousGenerator; +import eduni.simjava.distributions.Sim_uniform_obj; +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.GridletList; +import gridsim.auction.AuctionTags; +import gridsim.auction.MessageBid; +import gridsim.net.SimpleLink; + +import java.util.Iterator; + + +/** + * This class basically creates Gridlets and submits them to a + * particular Broker in a network topology. + */ +class NetUser extends GridSim +{ + private int myId_; // my entity ID + private GridletList jobs; // list of jobs to be executed + private GridletList receiveJobs; // list of received Gridlets + private Broker broker; + private ContinuousGenerator priceGenerator; + private int secondsBetweenJobs = 60; + + /** + * Creates a new NetUser object + * @param name this entity name + * @param totalGridlet total number of Gridlets to be created + * @param baud_rate the baud rate of the link to which this user is attached + * @param delay the delay of the link + * @param MTU the maximum transfer unit of the link + * @param broker the broker associated with this user + * @throws Exception This happens when name is null or haven't + * initialized GridSim. + */ + NetUser(String name, int totalGridlet, double baud_rate, double delay, + int MTU, Broker broker) throws Exception { + super( name, new SimpleLink(name+"_link",baud_rate,delay, MTU) ); + + this.receiveJobs = new GridletList(); + this.jobs = new GridletList(); + this.broker = broker; + + // Gets an ID for this entity + this.myId_ = super.getEntityId(name); + + // Creates a list of Gridlets or Tasks for this grid user + this.createGridlet(myId_, totalGridlet); + long seed = 11L*13*17*19*23+1; + priceGenerator = new Sim_uniform_obj("price",1, 2, seed); + } + + /** + * The core method that handles communications among GridSim entities. + */ + public void body() { + // wait for a little while for about 10 seconds. + // This to give a time for GridResource entities to register their + // services to GIS (GridInformationService) entity. + super.gridSimHold(10.0); + double previous = 0; + + Iterator it = jobs.iterator(); + while(it.hasNext()) { + previous += secondsBetweenJobs; + + MessageBid bid = new MessageBid(0, AuctionTags.CONTINUOUS_DOUBLE_AUCTION, + 1, super.get_id()); + + bid.setPrice(priceGenerator.sample()); + bid.setAttribute("job", it.next()); + + super.send(broker.get_id(), + secondsBetweenJobs, + AuctionTags.AUCTION_PROPOSE, bid); + } + + // hold for few period - few seconds since the Gridlets length are + // quite huge for a small bandwidth + super.gridSimHold(5); + + Object data; + Gridlet gl; + + Sim_event ev = new Sim_event(); + while ( Sim_system.running() ) + { + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // get the Gridlet data + if (data != null && data instanceof Gridlet) + { + gl = (Gridlet) data; + receiveJobs.add(gl); + } + + // if all the Gridlets have been collected + if (receiveJobs.size() == jobs.size()) { + break; + } + } + + super.send(broker.get_id(), GridSimTags.SCHEDULE_NOW, + Broker.FINISHED_EXPERIMENTS); + + //////////////////////////////////////////////////////// + // shut down I/O ports + shutdownUserEntity(); + terminateIOEntities(); + + +// super.send(broker.get_id(), GridSimTags.SCHEDULE_NOW, +// GridSimTags.END_OF_SIMULATION); + } + + /** + * Gets a list of received Gridlets + * @return a list of received/completed Gridlets + */ + public GridletList getGridletList() { + return receiveJobs; + } + + /** + * This method will show you how to create Gridlets + * @param userID owner ID of a Gridlet + * @param numGridlet number of Gridlet to be created + */ + private void createGridlet(int userID, int numGridlet) + { + int data = 500; // 500KB of data + for (int i = 0; i < numGridlet; i++) + { + // Creates a Gridlet + Gridlet gl = new Gridlet(i, data, data, data); + gl.setUserID(userID); + + // add this gridlet into a list + this.jobs.add(gl); + } + } + +} // end class + Added: trunk/examples/Auction/AuctionEx03/README.txt =================================================================== --- trunk/examples/Auction/AuctionEx03/README.txt (rev 0) +++ trunk/examples/Auction/AuctionEx03/README.txt 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,49 @@ + +/** + * Author: Anthony Sulistio + * Date: March 2006 + */ + + +Welcome to the Example of how to use GridSim auction extension. +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ExampleAuction.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ExampleAuction.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: + In Unix/Linux: java -classpath $GRIDSIM/jars/gridsim.jar:. ExampleAuction > file.txt + In Windows: java -classpath %GRIDSIM%\jars\gridsim.jar;. ExampleAuction > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, I renamed "file.txt" into +"output.txt" +NOTE: When you open "output.txt" file, it tells you that grid user entities + sending Gridlets to a selected grid resource. + + +When running the example file, it will produce the following files: + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + *.csv -> created by NetUser.java and gridsim.net.RIPRouter.java + to record every incoming activities. + The format of this file is: + simulation_time, ... + + where ... means other descriptive information. + +NOTE: sim_trace, sim_report and all *.csv files will be overwritten if running + a new experiment. Added: trunk/examples/Auction/AuctionEx03/ResponderImpl.java =================================================================== --- trunk/examples/Auction/AuctionEx03/ResponderImpl.java (rev 0) +++ trunk/examples/Auction/AuctionEx03/ResponderImpl.java 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,87 @@ +/* + * Author: Marcos Dias de Assuncao + * Date: May 2008 + * Description: A simple program to demonstrate of how to use GridSim + * auction extension package. + * This example shows how to create user, resource, auctioneer + * and auction entities connected via a network topology, + * using link and router. + * + */ + +import gridsim.AllocPolicy; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.auction.Message; +import gridsim.auction.MessageCallForBids; +import gridsim.auction.MessageInformOutcome; +import gridsim.auction.MessageInformStart; +import gridsim.auction.MessageRejectBid; +import gridsim.auction.Responder; + +/** + * This class implements a responder for an auction. + * + * @author Marcos Dias de Assuncao + * + */ +public class ResponderImpl implements Responder { + // this distribution is used to generate an + // internal price for the resource + private ResourceCharacteristics resource; + + /** + * Constructor (parameters are used just to ilustrate that the responder could + * take into account the usage of the resource or a give policy to formulate a bid + * @param resource + * @param calendar + * @param policy + * @throws Exception + */ + public ResponderImpl(ResourceCharacteristics resource, + ResourceCalendar calendar, + AllocPolicy policy) throws Exception{ + this.resource = resource; + } + + /** + * This method is invoked when a call for bids is received + * @param msg the call for bids received + * @return the reply message to the call for bids + * @see gridsim.auction.Responder#onReceiveCfb(MessageCallForBids) + */ + public Message onReceiveCfb(MessageCallForBids msg) { + return null; + } + + /** + * This method is invoked when an inform outcome message is received + * @param msg the inform outcome received + * @return the reply message to the inform outcome + * @see gridsim.auction.Responder#onReceiveInformOutcome(gridsim.auction.MessageInformOutcome) + */ + public Message onReceiveInformOutcome(MessageInformOutcome msg){ + return null; + } + + /** + * This method is invoked when a reject for proposal is received + * @param msg the reject proposal received + * @return the reply message to the reject proposal + * @see gridsim.auction.Responder#onReceiveRejectProposal(MessageRejectBid) + */ + public Message onReceiveRejectProposal(MessageRejectBid msg){ + return null; + } + + /** + * This method is invoked when an auction starts and an + * inform start message is received + * @param inform start received + * @return the reply message to the inform start + * @see gridsim.auction.Responder#onReceiveStartAuction(MessageInformStart) + */ + public Message onReceiveStartAuction(MessageInformStart inform){ + return null; + } +} \ No newline at end of file Added: trunk/examples/Auction/AuctionEx03/output.txt =================================================================== --- trunk/examples/Auction/AuctionEx03/output.txt (rev 0) +++ trunk/examples/Auction/AuctionEx03/output.txt 2008-05-27 07:55:44 UTC (rev 175) @@ -0,0 +1,106 @@ +Initializing GridSim package +Initialising... + +Starting to create one Grid resource with 3 Machines +Finally, creates one Grid resource (name: Resource_0 - id: 6) + + +Starting to create one Grid resource with 3 Machines +Finally, creates one Grid resource (name: Resource_1 - id: 12) + +User_0 creating a FPSA to acquire resource to execute job 0 from user 22 +User_0 creating an EA to acquire resource to execute job 1 from user 22 +User_0 creating a DA to acquire resource to execute job 2 from user 22 +User_1 creating a FPSA to acquire resource to execute job 0 from user 33 +User_1 creating an EA to acquire resource to execute job 1 from user 33 +User_1 creating a DA to acquire resource to execute job 2 from user 33 +User_2 creating a FPSA to acquire resource to execute job 0 from user 44 +User_2 creating an EA to acquire resource to execute job 1 from user 44 +User_2 creating a DA to acquire resource to execute job 2 from user 44 +Starting GridSim version 4.0 +Entities started. +Broker_0 starting the auction 0 to acquire resource to execute job 0 from user 22 +Broker_1 starting the auction 3 to acquire resource to execute job 0 from user 33 +Broker_2 starting the auction 6 to acquire resource to execute job 0 from user 44 +Broker_1 starting the auction 4 to acquire resource to execute job 1 from user 33 +Broker_2 starting the auction 7 to acquire resource to execute job 1 from user 44 +Broker_0 starting the auction 1 to acquire resource to execute job 1 from user 22 +Broker_2 starting the auction 8 to acquire resource to execute job 2 from user 44 +Broker_1 starting the auction 5 to acquire resource to execute job 2 from user 33 +Broker_0 starting the auction 2 to acquire resource to execute job 2 from user 22 +Resource_1 bidding for auction 2 round 2 and price 22.5 +Resource_0 bidding for auction 2 round 2 and price 22.5 +Resource_1 bidding for auction 5 round 2 and price 22.5 +Resource_0 bidding for auction 5 round 2 and price 22.5 +Resource_1 bidding for auction 8 round 2 and price 22.5 +Results of the auction +Winner ID: 12 +Price paid for executing the job 2: 22.5 +Submitted by user 22 +Resource_0 bidding for auction 8 round 2 and price 22.5 +Results of the auction +Winner ID: 12 +Price paid for executing the job 2: 22.5 +Submitted by user 33 +Results of the auction +Winner ID: 12 +Price paid for executing the job 2: 22.5 +Submitted by user 44 +Resource_1 bidding for auction 0 round 1 and price 7.62717866897583 +Resource_0 bidding for auction 0 round 1 and price 7.62717866897583 +Resource_1 bidding for auction 3 round 1 and price 7.017467021942139 +Resource_0 bidding for auction 3 round 1 and price 7.017467021942139 +Resource_1 bidding for auction 6 round 1 and price 2.2087604999542236 +Resource_0 bidding for auction 6 round 1 and price 2.2087604999542236 +Results of the auction +Winner ID: 12 +Price paid for executing the job 0: 7.62717866897583 +Submitted by user 22 +Results of the auction +Winner ID: 12 +Price paid for executing the job 0: 7.017467021942139 +Submitted by user 33 +Results of the auction +Winner ID: 12 +Price paid for executing the job 0: 2.2087604999542236 +Submitted by user 44 +Resource_1 bidding for auction 1 round 1 and price 90.0 +Resource_0 bidding for auction 1 round 1 and price 90.0 +Resource_1 bidding for auction 4 round 1 and price 90.0 +Resource_1 bidding for auction 7 round 1 and price 90.0 +Resource_0 bidding for auction 7 round 1 and price 90.0 +Resource_0 bidding for auction 4 round 1 and price 90.0 +Resource_1 bidding for auction 4 round 2 and price 67.5 +Resource_0 bidding for auction 1 round 2 and price 67.5 +Resource_1 bidding for auction 7 round 2 and price 67.5 +Resource_0 bidding for auction 4 round 2 and price 67.5 +Resource_1 bidding for auction 1 round 2 and price 67.5 +Resource_0 bidding for auction 7 round 2 and price 67.5 +Resource_1 bidding for auction 1 round 3 and price 45.0 +Resource_1 bidding for auction 4 round 3 and price 45.0 +Resource_0 bidding for auction 7 round 3 and price 45.0 +Resource_0 bidding for auction 1 round 3 and price 45.0 +Resource_1 bidding for auction 7 round 3 and price 45.0 +Resource_0 bidding for auction 4 round 3 and price 45.0 +Resource_1 bidding for auction 1 round 4 and price 22.5 +Resource_0 bidding for auction 1 round 4 and price 22.5 +Resource_1 bidding for auction 7 round 4 and price 22.5 +Resource_0 bidding for auction 7 round 4 and price 22.5 +Resource_1 bidding for auction 4 round 4 and price 22.5 +Resource_0 bidding for auction 4 round 4 and price 22.5 +Results of the auction +Winner ID: 12 +Price paid for executing the job 1: 22.5 +Submitted by user 22 +Results of the auction +Winner ID: 12 +Price paid for executing the job 1: 22.5 +Submitted by user 33 +Results of the auction +Winner ID: 12 +Price paid for executing the job 1: 22.5 +Submitted by user 44 +GridInformationService: Notify all GridSim entities for shutting down. +Sim_system: No more future events +Gathering simulation data. +Simulation completed. Modified: trunk/source/gridsim/auction/Auction.java =================================================================== --- trunk/source/gridsim/auction/Auction.java 2008-05-19 04:23:04 UTC (rev 174) +++ trunk/source/gridsim/auction/Auction.java 2008-05-27 07:55:44 UTC (rev 175) @@ -151,6 +151,19 @@ } /** + * Sets the auction's ID manually + * @param id the id to be used by the auction + * @return <tt>true</tt> if the ID has been set; <tt>false</tt> otherwise. + */ + public boolean setAuctionID(int id) { + if(id < 0) + return false; + + auctionID = id; + return true; + } + + /** * Returns the ID of this auction * @return auction ID */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-05-19 04:23:02
|
Revision: 174 http://gridsim.svn.sourceforge.net/gridsim/?rev=174&view=rev Author: marcos_dias Date: 2008-05-18 21:23:04 -0700 (Sun, 18 May 2008) Log Message: ----------- Small improvements in the allocation policies to allow the user to specify different forms to obtain alternative schedules for rejected advance reservations. Also, small changes in the Lublin 99 workload model have been made. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/WorkloadInterface.java branches/gridsim4.0-branch3/source/gridsim/util/Workload.java Removed Paths: ------------- branches/gridsim4.0-branch3/source/gridsim/util/Workload.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-05-19 04:23:04 UTC (rev 174) @@ -95,9 +95,9 @@ double uHi = Math.log(totalPE * totalMachine) / Math.log(2d); double uMed = uHi-2.5; - workload.setParallelJobProbabilities(Lublin99Workload.BATCH_JOBS, - workload.getParallelJobULow(Lublin99Workload.BATCH_JOBS), uMed, uHi, - workload.getParallelJobUProb(Lublin99Workload.BATCH_JOBS)); + workload.setParallelJobProbabilities(Lublin99Workload.INTERACTIVE_JOBS, + workload.getParallelJobULow(Lublin99Workload.INTERACTIVE_JOBS), uMed, uHi, + workload.getParallelJobUProb(Lublin99Workload.INTERACTIVE_JOBS)); // sets the workload to create 1000 jobs workload.setNumJobs(1000); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-05-19 04:23:04 UTC (rev 174) @@ -354,15 +354,18 @@ " PEs from " + startTime + " to " + sRes.getActualFinishTime()); System.out.println("--> The resource could not handle the reservation."); - // Gets availability information and provides it as options - AvailabilityInfo availability = super.allowBorrowing_ ? - getAvailabilityInfo(startTime, Integer.MAX_VALUE) : - getAvailabilityInfo(sRes.getPartitionID(), - startTime, Integer.MAX_VALUE); + // Gets availability information and provides it as options + AvailabilityInfo availability = getReservationAlternatives(sRes); + if(availability != null) { + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + } + else { + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + } + reservation.setStatus(Reservation.STATUS_FAILED); - reservation.setReservationOptions(availability); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); sendARMessage(response); return false; } @@ -907,6 +910,30 @@ return list; } + + /** + * Gets the reservation alternatives to be provided to the reservation + * requester or user in case a given advance reservation is not accepted.<br> + * <b>NOTE:</b> The default implementation of this method returns the + * resource availability information to the user. To do so, the method + * queries the availability using the reservation's start time as start time + * for the query and {@link Integer.MAX_VALUE} as the duration in seconds. + * If the policy allows borrowing of resources, all the resources are considered; + * otherwise, only the resources available to the partition to which the + * reservation falls are provided. + * @param sRes the server side reservation for which alternatives are to be given + * @return an availability object containing the resource availability or + * <tt>null</tt> in case no options are to be provided. + */ + protected AvailabilityInfo getReservationAlternatives(SSReservation sRes) { + // Gets availability information and provides it as options + AvailabilityInfo availability = super.allowBorrowing_ ? + getAvailabilityInfo(sRes.getStartTime(), Integer.MAX_VALUE) : + getAvailabilityInfo(sRes.getPartitionID(), + sRes.getStartTime(), Integer.MAX_VALUE); + + return availability; + } /** * Sends a reservation message. Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-05-19 04:23:04 UTC (rev 174) @@ -270,14 +270,14 @@ if (sRes.getStatus() == Reservation.STATUS_NOT_COMMITTED) { sRes.setStatus(Reservation.STATUS_COMMITTED); super.sendInternalEvent(resStartTime - currentTime, - CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + UPDATE_SCHEDULE_TAG); } // if the reservation has already started, then update the // schedule, which will force the gridlets in the queue to // be started else if(sRes.getStatus() == Reservation.STATUS_IN_PROGRESS) { super.sendInternalEvent(resStartTime - currentTime, - CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + UPDATE_SCHEDULE_TAG); } } @@ -362,15 +362,18 @@ " PEs from " + startTime + " to " + sRes.getActualFinishTime()); System.out.println("--> The resource could not handle the reservation."); - // Gets availability information and provides it as options - AvailabilityInfo availability = super.allowBorrowing_ ? - getAvailabilityInfo(startTime, Integer.MAX_VALUE) : - getAvailabilityInfo(sRes.getPartitionID(), - startTime, Integer.MAX_VALUE); - + // Gets availability information and provides it as options + AvailabilityInfo availability = getReservationAlternatives(sRes); + + if(availability != null) { + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + } + else { + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + } + reservation.setStatus(Reservation.STATUS_FAILED); - reservation.setReservationOptions(availability); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); sendARMessage(response); return false; } @@ -388,7 +391,7 @@ if(currentTime == startTime) { sRes.setStatus(Reservation.STATUS_COMMITTED); super.sendInternalEvent(GridSimTags.SCHEDULE_NOW, - CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + UPDATE_SCHEDULE_TAG); } else { sRes.setStatus(Reservation.STATUS_NOT_COMMITTED); @@ -478,7 +481,7 @@ // then send this into itself to start the reservation super.sendInternalEvent(sRes.getStartTime() - GridSim.clock(), - CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + UPDATE_SCHEDULE_TAG); } // sends the response message with no error @@ -739,7 +742,7 @@ startedReservations.add(sRes); super.sendInternalEvent(sRes.getActualFinishTime()-refTime, - CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + UPDATE_SCHEDULE_TAG); numStartedRes++; } @@ -915,6 +918,30 @@ return list; } + + /** + * Gets the reservation alternatives to be provided to the reservation + * requester or user in case a given advance reservation is not accepted.<br> + * <b>NOTE:</b> The default implementation of this method returns the + * resource availability information to the user. To do so, the method + * queries the availability using the reservation's start time as start time + * for the query and {@link Integer.MAX_VALUE} as the duration in seconds. + * If the policy allows borrowing of resources, all the resources are considered; + * otherwise, only the resources available to the partition to which the + * reservation falls are provided. + * @param sRes the server side reservation for which alternatives are to be given + * @return an availability object containing the resource availability or + * <tt>null</tt> in case no options are to be provided. + */ + protected AvailabilityInfo getReservationAlternatives(SSReservation sRes) { + // Gets availability information and provides it as options + AvailabilityInfo availability = super.allowBorrowing_ ? + getAvailabilityInfo(sRes.getStartTime(), Integer.MAX_VALUE) : + getAvailabilityInfo(sRes.getPartitionID(), + sRes.getStartTime(), Integer.MAX_VALUE); + + return availability; + } /** * Sends a reservation message. @@ -927,7 +954,7 @@ message.getMessageSize(), message.getDestinationID())); } - // ------------------------- PRIVATE MTHODS ---------------------- + // ------------------------- PRIVATE METHODS ---------------------- /** * Checks for expiry time of a given reservations in the list. @@ -982,7 +1009,6 @@ // backfills Gridlets to fill the fragment created by the // cancellation of the advance reservation super.backfillGridlets(currentTime); -// super.compressSchedule(referenceTime, false); //---------------- USED FOR DEBUGGING PURPOSES ONLY ---------------- Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-05-19 04:23:04 UTC (rev 174) @@ -205,39 +205,31 @@ // gets the reservation object and extract some // information from it Reservation reservation = message.getReservation(); - double startTime = reservation.getStartTime(); - int duration = reservation.getDurationTime(); - int reqPE = reservation.getNumPE(); // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); - double expTime = Double.NaN; - // creates a response message to be sent to the requester - ARMessage response = message.createResponse(); - //-------------- FOR DEBUGGING PURPOSES ONLY -------------- // informs the listeners that a reservation request has arrived GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sRes); //---------------------------------------------------------- - - if (reqPE > super.totalPE_) { - String userName = GridSim.getEntityName( message.getSourceID() ); - System.out.println(super.get_name() + ".handleCreateReservation():" + - " Reservation #" + reservation.getID() + " from " + - userName + " user requires " + reservation.getNumPE() + - " PEs from " + startTime + " to " + (startTime + duration)); - System.out.println("--> The resource has only " + - super.totalPE_ + " PEs available."); - + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + if(!validateReservation(sRes)){ reservation.setStatus(Reservation.STATUS_FAILED); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); sendARMessage(response); - return false; - } - + return false; + } + + double startTime = reservation.getStartTime(); + int duration = reservation.getDurationTime(); + int reqPE = reservation.getNumPE(); + double expTime = Double.NaN; boolean success = true; // if start time is 0, then it is an immediate reservation @@ -373,14 +365,19 @@ //---------------------------------------------------------- } else { // Creates a list of options - + // Gets availability information and provides it as options - AvailabilityInfo availability = - getAvailabilityInfo(startTime, Integer.MAX_VALUE); + AvailabilityInfo availability = getReservationAlternatives(sRes); - reservation.setStatus(Reservation.STATUS_FAILED); - reservation.setReservationOptions(availability); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + if(availability != null) { + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + } + else { + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + } + + reservation.setStatus(Reservation.STATUS_FAILED); sendARMessage(response); return false; } @@ -1109,6 +1106,29 @@ // ---------------------- PROTECTED METHODS ------------------------ /** + * Checks whether the reservation can be handled by the resource. That is, + * verifies if it does not require more resources than what the resource + * can provide. + * @param res the server side reservation to be examined + * @return <tt>true</tt> if it can be handled; <tt>false</tt> otherwise. + */ + protected boolean validateReservation(SSReservation res) { + int reqPE = res.getNumPE(); + if (reqPE > super.totalPE_) { + String userName = GridSim.getEntityName( res.getSenderID() ); + System.out.println(super.get_name() + ".validateReservation():" + + " Reservation #" + res.getID() + " from " + + userName + " user requires " + reqPE + + " PEs from " + res.getStartTime() + " to " + res.getActualFinishTime()); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs available."); + return false; + } + + return true; + } + + /** * This method is called to update the schedule. It removes completed * gridlets and return them to the users and verifies whether there are * gridlets in the waiting list that should start execution. It also @@ -1233,6 +1253,22 @@ return list; } + /** + * Gets the reservation alternatives to be provided to the reservation + * requester or user in case a given advance reservation is not accepted.<br> + * <b>NOTE:</b> The default implementation of this method returns the + * resource availability information to the user. To do so, the method + * queries the availability using the reservation's start time as start time + * for the query and {@link Integer.MAX_VALUE} as the duration in seconds. + * @param sRes the server side reservation for which alternatives are to be given + * @return an availability object containing the resource availability or + * <tt>null</tt> in case no options are to be provided. + */ + protected AvailabilityInfo getReservationAlternatives(SSReservation sRes) { + // Gets availability information + return getAvailabilityInfo(sRes.getStartTime(), Integer.MAX_VALUE); + } + /** * Search for a particular reservation in a data structure * @param obj a data structure Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-05-19 04:23:04 UTC (rev 174) @@ -59,19 +59,21 @@ * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 */ -public class Lublin99Workload extends GridSim { +public class Lublin99Workload extends + GridSim implements WorkloadInterface { private String resName_; // resource name private int resID_; // resource ID private int rating_; // a PE rating private int gridletID_; // gridletID private int size_; // job size for sending it through a network - private ArrayList<Gridlet> list_; // a list for getting all the Gridlets - private Random random_ = null; // the number generator to be used + private ArrayList<Gridlet> list_; // a list for getting all the Gridlets + private Random random_ = null; // the number generator to be used + private int gridletsReturned_; // starts at 1, since gridletID_ starts at 1 too + private long lastSubmissionTime_; // Log PI for log gamma method private static final double LOGPI = 1.14472988584940017414; - private final int INTERVAL = 10; // number of intervals private static final int UNKNOWN = -1; // ------------ CONSTANTS USED BY THE WORKLOAD MODEL -------------- @@ -182,7 +184,7 @@ /* * Here are the model's parameters for typeless data (no batch nor interactive) - * We use those parameters when INCLUDE_JOBS_TYPE is off (0) + * We use those parameters when useJobType_ is false */ private static final double SERIAL_PROB = 0.244; private static final double POW2_PROB = 0.576; @@ -437,6 +439,7 @@ private void init(String resourceName, int rating, boolean useJobType, long seed) { + lastSubmissionTime_ = -1; useJobType_ = useJobType; resName_ = resourceName; resID_ = GridSim.getEntityId(resName_); @@ -464,16 +467,16 @@ if (useJobType_) { serialProb[BATCH_JOBS] = SERIAL_PROB_BATCH; pow2Prob[BATCH_JOBS] = POW2_PROB_BATCH; - uLow[BATCH_JOBS] = ULOW_BATCH; - uMed[BATCH_JOBS] = UMED_BATCH; - uHi[BATCH_JOBS] = UHI_BATCH; + uLow[BATCH_JOBS] = ULOW_BATCH; + uMed[BATCH_JOBS] = UMED_BATCH; + uHi[BATCH_JOBS] = UHI_BATCH; uProb[BATCH_JOBS] = UPROB_BATCH; serialProb[INTERACTIVE_JOBS] = SERIAL_PROB_ACTIVE; pow2Prob[INTERACTIVE_JOBS] = POW2_PROB_ACTIVE; uLow[INTERACTIVE_JOBS] = ULOW_ACTIVE; uMed[INTERACTIVE_JOBS] = UMED_ACTIVE; - uHi[INTERACTIVE_JOBS] = UHI_ACTIVE; + uHi[INTERACTIVE_JOBS] = UHI_ACTIVE; uProb[INTERACTIVE_JOBS] = UPROB_ACTIVE; a1[BATCH_JOBS] = A1_BATCH; b1[BATCH_JOBS] = B1_BATCH; @@ -493,13 +496,13 @@ bnum[INTERACTIVE_JOBS] = BNUM_ACTIVE; } else { - // whole sample -- make all batch jobs + // whole sample -- make all interactive jobs serialProb[BATCH_JOBS] = serialProb[INTERACTIVE_JOBS] = SERIAL_PROB; pow2Prob[BATCH_JOBS] = pow2Prob[INTERACTIVE_JOBS] = POW2_PROB; - uLow[BATCH_JOBS] = uLow[INTERACTIVE_JOBS] = ULOW ; - uMed[BATCH_JOBS] = uMed[INTERACTIVE_JOBS] = UMED ; - uHi[BATCH_JOBS] = uHi[INTERACTIVE_JOBS] = UHI ; - uProb[BATCH_JOBS] = uProb[INTERACTIVE_JOBS] = UPROB ; + uLow[BATCH_JOBS] = uLow[INTERACTIVE_JOBS] = ULOW; + uMed[BATCH_JOBS] = uMed[INTERACTIVE_JOBS] = UMED; + uHi[BATCH_JOBS] = uHi[INTERACTIVE_JOBS] = UHI; + uProb[BATCH_JOBS] = uProb[INTERACTIVE_JOBS] = UPROB; a1[BATCH_JOBS] = a1[INTERACTIVE_JOBS] = A1; b1[BATCH_JOBS] = b1[INTERACTIVE_JOBS] = B1; @@ -514,8 +517,11 @@ bnum[BATCH_JOBS] = bnum[INTERACTIVE_JOBS] = BNUM; } - if ( ! useJobType_ ) // make all jobs batch - timeFromBegin_[INTERACTIVE_JOBS] = Long.MAX_VALUE; +// if ( ! useJobType_ ) // make all jobs batch +// timeFromBegin_[INTERACTIVE_JOBS] = Long.MAX_VALUE; + + if ( ! useJobType_ ) // make all jobs interactive + timeFromBegin_[BATCH_JOBS] = Long.MAX_VALUE; } /** @@ -820,7 +826,7 @@ * Sets the maximum number of jobs to be generated by this workload model * @param numJobs the number of jobs * @return <tt>true</tt> if the number of jobs has been set; - * <tt>false</tt> othwerwise. + * <tt>false</tt> otherwise. */ public boolean setNumJobs(int numJobs) { if(numJobs < 1) @@ -967,11 +973,12 @@ // if all the gridlets have been submitted if (success == true) { - collectGridlet(); + finishGridletSubmission(lastSubmissionTime_); + processEvents(); } else { System.out.println(super.get_name() + - ".body(): Error - unable to parse from a file."); + ".body(): Error - unable to create the gridlets."); } // shut down all the entities, including GridStatistics entity since @@ -986,45 +993,44 @@ //////////////////////// PROTECTED METHODS /////////////////////// /** - * Collects Gridlets sent and stores them into a list. - * @pre $none + * Processes events such as receiving of gridlets. * @post $none */ - protected void collectGridlet() { + protected void processEvents() { System.out.println(super.get_name() + ": Collecting Gridlets ..."); list_ = new ArrayList<Gridlet>(gridletID_ + 1); + gridletsReturned_ = 1; // starts at 1, since gridletID_ starts at 1 too Object data = null; Gridlet gl = null; - int counter = 1; // starts at 1, since gridletID_ starts at 1 too Sim_event ev = new Sim_event(); while ( Sim_system.running() ) { super.sim_get_next(ev); // get the next available event + + // get the Gridlet data data = ev.get_data(); // get the event's data // handle ping request - if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) - { + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { processPingRequest(ev); continue; } - - // get the Gridlet data - if (data != null && data instanceof Gridlet) { - gl = (Gridlet) data; - list_.add(gl); - counter++; + else if (data != null && data instanceof Gridlet) { + onGridletReceipt((Gridlet)data); } + else { + processOtherEvent(ev); + } // if all the Gridlets have been collected - if (counter == gridletID_) { + if (gridletsReturned_ == gridletID_) { break; } } } - + /** * Processes a ping request. * @param ev a Sim_event object @@ -1051,6 +1057,9 @@ * <tt>false</tt> otherwise. */ private boolean createGridlets() { + + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); int type = INTERACTIVE_JOBS; int nodes; long arrTime; int runTime; @@ -1072,12 +1081,58 @@ runTime = (int)timeFromNodes(a1[type], b1[type], a2[type], b2[type], pa[type], pb[type], nodes); - submitGridlet(i+1, arrTime, runTime, nodes); + onGridletCreation(i+1, arrTime, runTime, nodes); } return true; } + /** + * This method is called by the workload model once information for a + * gridlet is created by the model. + * @param gridletId the id assigned to the gridlet + * @param submitTime the time the gridlet should be submitted + * @param runTime the runtime estimate for the gridlet + * @param numProc the number of processors required by the gridlet + * @see gridsim.turbo.WorkloadInterface#onGridletCreation(int, long, int, int) + */ + public void onGridletCreation(int gridletId, long submitTime, + int runTime, int numProc) { + submitGridlet(gridletId, submitTime, runTime, numProc); + } + + /** + * Invoked by the workload implementation when an event could not + * be handled. + * @param ev the event to be handled. + */ + public void processOtherEvent(Sim_event ev) { + System.out.println(get_name() + ": could not handle event with tag " + + ev.get_tag()); + } + + /** + * This method is invoked by the workload reader/model upon the scheduling + * of the last gridlet created. This is useful in case the user wants to + * schedule an event to cancel the simulation at the submission of the last + * job to avoid the cool down phase of the simulation. + * @param lastSubmissionTime the time when the last gridlet + * submission took place + */ + public void finishGridletSubmission(double lastSubmissionTime) { + return; + } + + /** + * This method is invoked when a Gridlet is returned by the resource + * back to a workload model or trace reader. + * @param grl the gridlet returned by the resource + */ + public void onGridletReceipt(Gridlet grl) { + list_.add(grl); + gridletsReturned_++; + } + /* * We distinguish between serial jobs , power2 jobs and other. * for serial job (with probability SerialProb) the number of nodes is 1 @@ -1177,7 +1232,7 @@ for (int i=moveto ; i<BUCKETS+moveto ; i++) { idx = (i-1)%BUCKETS; /* i-1 since array indices are 0..47 and not 1..48 */ weights[j][idx] = - gamcdf(i+0.5, anum[j], bnum[j]) - gamcdf(i-0.5, anum[j],bnum[j]); + gamcdf(((double)i)+0.5, anum[j], bnum[j]) - gamcdf(((double)i)-0.5, anum[j],bnum[j]); mean[j] += weights[j][idx]; } mean[j] /= BUCKETS; @@ -1276,19 +1331,13 @@ gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) - { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - // check the submit time if (submitTime < 0) { submitTime = 0; } gridletID_++; // increment the counter + lastSubmissionTime_ = submitTime; // submit a gridlet to resource super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, @@ -1372,6 +1421,22 @@ return (beta * x * y); } +// /* +// * betarndLess1 returns a value of a random variable of beta(alpha,beta) +// * distribution where both alpha and beta are smaller than 1 (and larger +// * than 0) +// */ +// private double betarndLess1(double alpha, double beta) { +// double x, y, u1, u2; +// do { +// u1 = random_.nextDouble(); +// u2 = random_.nextDouble(); +// x = Math.pow(u1, 1 / alpha); +// y = Math.pow(u2, 1 / beta); +// } while (x + y > 1); +// return (x / (x + y)); +// } + /* * betarndLess1 returns a value of a random variable of beta(alpha,beta) * distribution where both alpha and beta are smaller than 1 (and larger @@ -1382,8 +1447,8 @@ do { u1 = random_.nextDouble(); u2 = random_.nextDouble(); - x = Math.pow(u1, 1 / alpha); - y = Math.pow(u2, 1 / beta); + x = Math.pow(u1, 1D / alpha); + y = Math.pow(u2, 1D / beta); } while (x + y > 1); return (x / (x + y)); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-05-19 04:23:04 UTC (rev 174) @@ -65,7 +65,7 @@ * @return a collection with the partitions in this * profile. */ - protected Collection<QueuePartition> getPartitions() { + public Collection<QueuePartition> getPartitions() { //TODO: To find a better way to do it... return queues_.values(); } @@ -1058,7 +1058,7 @@ * smaller, or whose time is equals to <tt>time</tt>; <tt>null</tt> if * not found. */ - protected MPProfileEntry getPrecedingEntry(double time) { + public MPProfileEntry getPrecedingEntry(double time) { Iterator<MPProfileEntry> it = super.iterator(); MPProfileEntry preceding = null; Added: branches/gridsim4.0-branch3/source/gridsim/turbo/WorkloadInterface.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/WorkloadInterface.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/WorkloadInterface.java 2008-05-19 04:23:04 UTC (rev 174) @@ -0,0 +1,63 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +import eduni.simjava.Sim_event; +import gridsim.Gridlet; + +/** + * The main purpose of this interface is to give the user flexibility in creating + * entities that generate gridlets according to a trace file or a workload model. + * + * In other words, this interface defines methods that allow the user + * to change the behaviour of the entity when a new job is generated, or + * when jobs are returned by the resource providers. + * + * @author Marcos Dias de Assuncao + * + * @since GridSim Turbo Alpha 0.1 + * @invariant $none + */ +public interface WorkloadInterface { + + /** + * This method is called by a workload generator or model when once + * information for a gridlet is read from a log file or created by the model. + * @param gridletId the id assigned to the gridlet + * @param submitTime the time the gridlet should be submitted + * @param runTime the runtime estimate for the gridlet + * @param numProc the number of processors required by the gridlet + */ + void onGridletCreation(int gridletId, long submitTime, + int runTime, int numProc); + + /** + * This method is invoked when a Gridlet is returned by the resource + * back to a workload model or trace reader. + * @param grl the gridlet returned by the resource + */ + void onGridletReceipt(Gridlet grl); + + /** + * This method is invoked by the workload reader/model upon the scheduling + * of the last gridlet created. This is useful in case the user wants to + * schedule an event to cancel the simulation at the submission of the last + * job to avoid the cool down phase of the simulation. + * @param lastSubmissionTime the time when the last gridlet + * submission took place + */ + void finishGridletSubmission(double lastSubmissionTime); + + /** + * Invoked by the workload implementation when an event could not + * be handled. + * @param ev the event to be handled. + */ + void processOtherEvent(Sim_event ev); +} + Deleted: branches/gridsim4.0-branch3/source/gridsim/util/Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/util/Workload.java 2008-05-11 00:55:20 UTC (rev 173) +++ branches/gridsim4.0-branch3/source/gridsim/util/Workload.java 2008-05-19 04:23:04 UTC (rev 174) @@ -1,939 +0,0 @@ -/* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - */ - -package gridsim.util; - -import eduni.simjava.*; -import gridsim.*; -import gridsim.net.*; - -// below packages are needed to read a file -import java.util.*; -import java.util.zip.*; -import java.io.*; - -/** - * The main purpose of this class is to create a realistic simulation - * environment where your jobs or Gridlets are competing with others. - * In other words, the grid resource might not be available at certain times. - * In addition, the arrival time of jobs are also captured in the trace file. - * <p> - * This class is responsible for reading resource traces from a file and - * sends Gridlets to only <tt>one</tt> destinated resource. <br> - * <b>NOTE:</b> - * <ul> - * <li> This class can only take <tt>one</tt> trace file of the following - * format: <i>ASCII text, zip, gz.</i> - * <li> This class can be classified as <b>one grid user entity</b>. - * Hence, you need to incorporate this entity into <tt>numUser</tt> - * during {@link gridsim.GridSim#init(int, Calendar, boolean)} - * <li> If you need to use multiple trace files to submit Gridlets to - * same or different resources, then you need to create multiple - * instances of this class <tt>each with a unique entity name</tt>. - * <li> If size of the trace file is huge or contains lots of traces - * please increase the JVM heap size accordingly by using - * <tt>java -Xmx</tt> option when running the simulation. - * <li> If you are running an experiment using the network extension, - * i.e. the gridsim.net package, then you need to use - * {@link #Workload(String, double, double, int, String, String, int)} - * instead. - * <li> The default job file size for sending to and receiving from - * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. - * However, you can specify - * the file size by using {@link #setGridletFileSize(int)}. - * <li> A job run time is only for 1 PE <tt>not</tt> the total number of - * allocated PEs. - * Therefore, a Gridlet length is also calculated for 1 PE.<br> - * For example, job #1 in the trace has a run time of 100 seconds - * for 2 processors. This means each processor runs - * job #1 for 100 seconds, if the processors have the same - * specification. - * </ul> - * <p> - * By default, this class follows the standard workload format as specified - * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> - * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> - * However, you can use other format by calling the below methods before - * running the simulation: - * <ul> - * <li> {@link #setComment(String)} - * <li> {@link #setField(int, int, int, int, int)} - * </ul> - * - * @see gridsim.GridSim#init(int, Calendar, boolean) - * @author Anthony Sulistio - * @since GridSim Toolkit 3.1 - * @invariant $none - */ -public class Workload extends GridSim -{ - protected String fileName_; // file name - protected String resName_; // resource name - protected int resID_; // resource ID - protected int rating_; // a PE rating - protected int gridletID_; // gridletID - protected int size_; // job size for sending it through a network - protected ArrayList list_; // a list for getting all the Gridlets - - // constant - private int JOB_NUM; // job number - private int SUBMIT_TIME; // submit time of a Gridlet - private int RUN_TIME; // running time of a Gridlet - private int NUM_PROC; // number of processors needed for a Gridlet - private int REQ_NUM_PROC; // required number of processors - private int REQ_RUN_TIME; // required running time - private int MAX_FIELD; // max number of field in the trace file - private String COMMENT; // a string that denotes the start of a comment - private final int IRRELEVANT = -1; // irrelevant number - private String[] fieldArray_; // a temp array storing all the fields - - /** - * Create a new Workload object <b>without</b> using the network extension. - * This means this entity directly sends Gridlets to a destination resource - * without going through a wired network. <br> - * <tt>NOTE:</tt> - * You can not use this constructor in an experiment that uses a wired - * network topology. - * - * @param name this entity name - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public Workload(String name, String fileName, String resourceName, - int rating) throws ParameterException, Exception - { - super(name, GridSimTags.DEFAULT_BAUD_RATE); - - // check the input parameters first - String msg = name + "(): Error - "; - if (fileName == null || fileName.length() == 0) { - throw new ParameterException(msg + "invalid trace file name."); - } - else if (resourceName == null || resourceName.length() == 0) { - throw new ParameterException(msg + "invalid resource name."); - } - else if (rating <= 0) { - throw new ParameterException(msg+"resource PE rating must be > 0."); - } - - System.out.println(name + ": Creating a workload object ..."); - init(fileName, resourceName, rating); - } - - /** - * Create a new Workload object <b>with</b> the network extension. - * This means this entity directly sends Gridlets to a destination resource - * through a link. The link is automatically created by this constructor. - * - * @param name this entity name - * @param baudRate baud rate of this link (bits/s) - * @param propDelay Propagation delay of the Link in milliseconds - * @param MTU Maximum Transmission Unit of the Link in bytes. - * Packets which are larger than the MTU should be split - * up into MTU size units. - * For example, a 1024 byte packet trying to cross a 576 - * byte MTU link should get split into 2 packets of 576 - * bytes and 448 bytes. - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li> baudRate <= 0 - * <li> propDelay <= 0 - * <li> MTU <= 0 - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre baudRate > 0 - * @pre propDelay > 0 - * @pre MTU > 0 - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public Workload(String name, double baudRate, double propDelay, int MTU, - String fileName, String resourceName, int rating) - throws ParameterException, Exception - { - super( name, new SimpleLink(name+"_link", baudRate, propDelay, MTU) ); - - // check the input parameters first - String msg = name + "(): Error - "; - if (fileName == null || fileName.length() == 0) { - throw new ParameterException(msg + "invalid trace file name."); - } - else if (resourceName == null || resourceName.length() == 0) { - throw new ParameterException(msg + "invalid resource name."); - } - else if (rating <= 0) { - throw new ParameterException(msg+"resource PE rating must be > 0."); - } - - System.out.println(name + ": Creating a workload object ..."); - init(fileName, resourceName, rating); - } - - /** - * Create a new Workload object <b>with</b> the network extension. - * This means this entity directly sends Gridlets to a destination resource - * through a link. The link is automatically created by this constructor. - * - * @param name this entity name - * @param link the link that will be used to connect this Workload - * to another entity or a Router. - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li>the link is empty - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre link != null - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public Workload(String name, Link link, String fileName, - String resourceName, int rating) - throws ParameterException, Exception - { - super(name, link); - - // check the input parameters first - String msg = name + "(): Error - "; - if (fileName == null || fileName.length() == 0) { - throw new ParameterException(msg + "invalid trace file name."); - } - else if (resourceName == null || resourceName.length() == 0) { - throw new ParameterException(msg + "invalid resource name."); - } - else if (rating <= 0) { - throw new ParameterException(msg+"resource PE rating must be > 0."); - } - - System.out.println(name + ": Creating a workload object ..."); - init(fileName, resourceName, rating); - } - - /** - * Initialises all the attributes - * @param fileName trace file name - * @param resourceName resource entity name - * @param rating resource PE rating - * @pre $none - * @post $none - */ - private void init(String fileName, String resourceName, int rating) - { - fileName_ = fileName; - resName_ = resourceName; - resID_ = GridSim.getEntityId(resName_); - rating_ = rating; - gridletID_ = 1; // starts at 1 to make it the same as in a trace file - list_ = null; - size_ = Link.DEFAULT_MTU; - - // if using Standard Workload Format -- don't forget to substract by 1 - // since an array starts at 0, but the field in a trace starts at 1 - JOB_NUM = 1 - 1; - SUBMIT_TIME = 2 - 1; - RUN_TIME = 4 - 1; - NUM_PROC = 5 - 1; - REQ_NUM_PROC = 8 - 1; - REQ_RUN_TIME = 9 - 1; - - COMMENT = ";"; // semicolon means the start of a comment - MAX_FIELD = 18; // standard workload format has 18 fields - fieldArray_ = null; - } - - /** - * Sets a Gridlet file size (in byte) for sending to/from a resource. - * @param size a Gridlet file size (in byte) - * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise - * @pre size > 0 - * @post $none - */ - public boolean setGridletFileSize(int size) - { - if (size < 0) { - return false; - } - - size_ = size; - return true; - } - - /** - * Identifies the start of a comment line. Hence, a line that starts - * with a given comment will be ignored. - * @param comment a character that denotes the start of a comment, - * e.g. ";" or "#" - * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise - * @pre comment != null - * @post $none - */ - public boolean setComment(String comment) - { - boolean success = false; - if (comment != null && comment.length() > 0) - { - COMMENT = comment; - success = true; - } - return success; - } - - /** - * Tells this class what to look in the trace file. - * This method should be called before the start of the simulation. - * <p> - * By default, this class follows the standard workload format as specified - * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> - * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> - * However, you can use other format by calling this method. - * <p> - * The parameters must be a positive integer number starting from 1. - * A special case is where <tt>jobNum == -1</tt>, meaning the job or - * gridlet ID starts at 1. - * - * @param maxField max. number of field/column in one row - * @param jobNum field/column number for locating the job ID - * @param submitTime field/column number for locating the job submit time - * @param runTime field/column number for locating the job run time - * @param numProc field/column number for locating the number of PEs - * required to run a job - * @return <tt>true</tt> if successful, <tt>false</tt> otherwise - * @pre maxField > 0 - * @pre submitTime > 0 - * @pre runTime > 0 - * @pre numProc > 0 - * @post $none - */ - public boolean setField(int maxField, int jobNum, int submitTime, - int runTime, int numProc) - { - // need to substract by 1 since array starts at 0. Need to convert, - // position in a field into the index of the array - if (jobNum > 0) { - JOB_NUM = jobNum - 1; - } - else if (jobNum == 0) - { - System.out.println(super.get_name() + - ".setField(): Invalid job number field."); - return false; - } - else { - JOB_NUM = -1; - } - - // get the max. number of field - if (maxField > 0) { - MAX_FIELD = maxField; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid max. number of field."); - return false; - } - - // get the submit time field - if (submitTime > 0) { - SUBMIT_TIME = submitTime - 1; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid submit time field."); - return false; - } - - // get the run time field - if (runTime > 0) { - REQ_RUN_TIME = runTime - 1; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid run time field."); - return false; - } - - // get the number of processors field - if (numProc > 0) { - REQ_NUM_PROC = numProc - 1; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid number of processors field."); - return false; - } - - return true; - } - - /** - * Gets a list of completed Gridlets - * @return a list of Gridlets - * @pre $none - * @post $none - */ - public ArrayList getGridletList() { - return list_; - } - - /** - * Prints the Gridlet objects - * @param history <tt>true</tt> means printing each Gridlet's history, - * <tt>false</tt> otherwise - * @pre $none - * @post $none - */ - public void printGridletList(boolean history) - { - String name = super.get_name(); - int size = list_.size(); - Gridlet gridlet; - - String indent = " "; - System.out.println(); - System.out.println("========== OUTPUT for " + name + " =========="); - System.out.println("Gridlet_ID" + indent + "STATUS" + indent + - "Resource_ID" + indent + "Cost"); - - int i = 0; - for (i = 0; i < size; i++) - { - gridlet = (Gridlet) list_.get(i); - System.out.print(indent + gridlet.getGridletID() + indent - + indent); - - // get the status of a Gridlet - System.out.print( gridlet.getGridletStatusString() ); - System.out.println( indent + indent + gridlet.getResourceID() + - indent + indent + gridlet.getProcessingCost() ); - } - - System.out.println(); - if (history == true) - { - // a loop to print each Gridlet's history - System.out.println(); - for (i = 0; i < size; i++) - { - gridlet = (Gridlet) list_.get(i); - System.out.println( gridlet.getGridletHistory() ); - - System.out.print("Gridlet #" + gridlet.getGridletID() ); - System.out.println(", length = " + gridlet.getGridletLength() - + ", finished so far = " - + gridlet.getGridletFinishedSoFar() ); - System.out.println("========================================="); - System.out.println(); - } - } - } - - /** - * Reads from a given file when the simulation starts running. - * Then submits Gridlets to a resource and collects them before exiting. - * To collect the completed Gridlets, use {@link #getGridletList()} - * @pre $none - * @post $none - */ - public void body() - { - System.out.println(); - System.out.println(super.get_name() + ".body() :%%%% Start ..."); - - // create a temp array - fieldArray_ = new String[MAX_FIELD]; - - // get the resource id - if (resID_ < 0) - { - System.out.println(super.get_name() + - ".body(): Error - invalid resource name: " + resName_); - return; - } - - boolean success = false; - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - - // read the gz file - if (fileName_.endsWith(".gz") == true) { - success = readGZIPFile(fileName_); - } - // read the zip file - else if (fileName_.endsWith(".zip") == true) { - success = readZipFile(fileName_); - } - // read from uncompressed file as well - else { - success = readFile(fileName_); - } - - // help the garbage collector - fieldArray_ = null; - - // if all the gridlets have been submitted - if (success == true) { - collectGridlet(); - } - else - { - System.out.println(super.get_name() + - ".body(): Error - unable to parse from a file."); - } - - // shut down all the entities, including GridStatistics entity since - // we used it to record certain events. - shutdownGridStatisticsEntity(); - shutdownUserEntity(); - terminateIOEntities(); - - System.out.println(super.get_name() + ".body() : %%%% Exit ..."); - } - - //////////////////////// PROTECTED METHODS /////////////////////// - - /** - * Collects Gridlets sent and stores them into a list. - * @pre $none - * @post $none - */ - protected void collectGridlet() - { - System.out.println(super.get_name() + ": Collecting Gridlets ..."); - list_ = new ArrayList(gridletID_ + 1); - - Object data = null; - Gridlet gl = null; - - int counter = 1; // starts at 1, since gridletID_ starts at 1 too - Sim_event ev = new Sim_event(); - while ( Sim_system.running() ) - { - super.sim_get_next(ev); // get the next available event - data = ev.get_data(); // get the event's data - - // handle ping request - if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) - { - processPingRequest(ev); - continue; - } - - // get the Gridlet data - if (data != null && data instanceof Gridlet) - { - gl = (Gridlet) data; - list_.add(gl); - counter++; - } - - // if all the Gridlets have been collected - if (counter == gridletID_) { - break; - } - } - } - - /** - * Processes a ping request. - * @param ev a Sim_event object - * @pre ev != null - * @post $none - */ - protected void processPingRequest(Sim_event ev) - { - InfoPacket pkt = (InfoPacket) ev.get_data(); - pkt.setTag(GridSimTags.INFOPKT_RETURN); - pkt.setDestID( pkt.getSrcID() ); - - // sends back to the sender - super.send(super.output, GridSimTags.SCHEDULE_NOW, - GridSimTags.INFOPKT_RETURN, - new IO_data(pkt, pkt.getSize(), pkt.getSrcID()) ); - } - - //////////////////////// PRIVATE METHODS /////////////////////// - - /** - * Breaks a line of string into many fields. - * @param line a line of string - * @param lineNum a line number - * @pre line != null - * @pre lineNum > 0 - * @post $none - */ - private void parseValue(String line, int lineNum) - { - // skip a comment line - if (line.startsWith(COMMENT) == true) { - return; - } - - String[] sp = line.split("\\s+"); // split the fields based on a space - int i; // a counter - int len = 0; // length of a string - int index = 0; // the index of an array - - // check for each field in the array - for (i = 0; i < sp.length; i++) - { - len = sp[i].length(); // get the length of a string - - // if it is empty then ignore - if (len == 0) { - continue; - } - // if not, then put into the array - else - { - fieldArray_[index] = sp[i]; - index++; - } - } - - if (index == MAX_FIELD) { - extractField(fieldArray_, lineNum); - } - } - - /** - * Extracts relevant information from a given array - * @param array an array of String - * @param line a line number - * @pre array != null - * @pre line > 0 - */ - private void extractField(String[] array, int line) - { - try - { - Integer obj = null; - - // get the job number - int id = 0; - if (JOB_NUM == IRRELEVANT) { - id = gridletID_; - } - else { - obj = new Integer( array[JOB_NUM].trim() ); - id = obj.intValue(); - } - - // get the submit time - Long l = new Long( array[SUBMIT_TIME].trim() ); - long submitTime = l.intValue(); - - // get the run time - obj = new Integer( array[REQ_RUN_TIME].trim() ); - int runTime = obj.intValue(); - - // if the required run time field is ignored, then use - // the actual run time - if (runTime == IRRELEVANT) - { - obj = new Integer( array[RUN_TIME].trim() ); - runTime = obj.intValue(); - } - - // according to the SWF manual, runtime of 0 is possible due - // to rounding down. E.g. runtime is 0.4 seconds -> runtime = 0 - if (runTime == 0) { - runTime = 1; // change to 1 second - } - - // get the number of allocated processors - obj = new Integer( array[REQ_NUM_PROC].trim() ); - int numProc = obj.intValue(); - - // if the required num of allocated processors field is ignored - // or zero, then use the actual field - if (numProc == IRRELEVANT || numProc == 0) - { - obj = new Integer( array[NUM_PROC].trim() ); - numProc = obj.intValue(); - } - - // finally, check if the num of PEs required is valid or not - if (numProc <= 0) - { - System.out.println(super.get_name() + ": Warning - job #" - + id + " at line " + line + " requires " + numProc - + " CPU. Change to 1 CPU."); - numProc = 1; - } - - // submit a Gridlet - submitGridlet(id, submitTime, runTime, numProc); - } - catch (Exception e) - { - System.out.println(super.get_name() + - ": Exception in reading file at line #" + line); - e.printStackTrace(); - } - } - - /** - * Creates a Gridlet with the given information, then submit it to a - * resource - * @param id a Gridlet ID - * @param submitTime Gridlet's submit time - * @param runTime Gridlet's actual run time - * @param numProc number of processors - * @pre id >= 0 - * @pre submitTime >= 0 - * @pre runTime >= 0 - * @pre numProc > 0 - * @post $none - */ - protected void submitGridlet(int id, long submitTime, - int runTime, int numProc) - { - // create the gridlet - int len = runTime * rating_; // calculate a job length for each PE - Gridlet gl = new Gridlet(id, len, size_, size_, GridSim.isTraceEnabled()); - gl.setUserID( super.get_id() ); // set the owner ID - gl.setNumPE(numProc); // set the requested num of proc - - // check the submit time - if (submitTime < 0) { - submitTime = 0; - ... [truncated message content] |
From: <mar...@us...> - 2008-05-11 00:55:14
|
Revision: 173 http://gridsim.svn.sourceforge.net/gridsim/?rev=173&view=rev Author: marcos_dias Date: 2008-05-10 17:55:20 -0700 (Sat, 10 May 2008) Log Message: ----------- Just a small fix in case the user does not want to specify an heuristic to order jobs in multiple partition policies. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-05-08 07:44:14 UTC (rev 172) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-05-11 00:55:20 UTC (rev 173) @@ -511,7 +511,8 @@ // iterates the waiting queue and for each gridlet, put the ranges // used back in the profile. That is, updates the entries - Collections.sort(queuedGridlets_, jobOrderHeuristic_); + if(jobOrderHeuristic_ != null) + Collections.sort(queuedGridlets_, jobOrderHeuristic_); Iterator<SSGridlet> iterQueue = queuedGridlets_.iterator(); while(iterQueue.hasNext()) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-05-08 07:44:14 UTC (rev 172) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-05-11 00:55:20 UTC (rev 173) @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.Iterator; -import java.util.LinkedList; /** * This class implements a non-FCFS policy to schedule parallel jobs. The @@ -76,7 +75,7 @@ public class EBMultiplePartitions extends TAllocPolicy { // Queue of running Gridlets - protected LinkedList<SSGridlet> runningGridlets_; + protected ArrayList<SSGridlet> runningGridlets_; // Queue of Gridlets waiting in this queue protected ArrayList<SSGridlet> queuedGridlets_; @@ -156,7 +155,7 @@ } // initialises local data structure - runningGridlets_ = new LinkedList<SSGridlet>(); + runningGridlets_ = new ArrayList<SSGridlet>(); queuedGridlets_ = new ArrayList<SSGridlet>(); jobOrderHeuristic_ = new OrderGridletsByPriority(); numPartitions_ = numPartitions; @@ -1039,7 +1038,8 @@ } // order gridlets according to the job ordering heuristic provided - Collections.sort(queuedGridlets_, jobOrderHeuristic_); + if(jobOrderHeuristic_ != null) + Collections.sort(queuedGridlets_, jobOrderHeuristic_); // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than reference time This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-05-08 07:44:12
|
Revision: 172 http://gridsim.svn.sourceforge.net/gridsim/?rev=172&view=rev Author: marcos_dias Date: 2008-05-08 00:44:14 -0700 (Thu, 08 May 2008) Log Message: ----------- Small improvements in the allocation policies to allow the user to extend the advance reservation methods and implement his own logging features. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-05-08 07:44:14 UTC (rev 172) @@ -294,29 +294,40 @@ /** * Handles an advance reservation request.<br> * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation has been accepted; + * <tt>false</tt> otherwise. * @pre message != null */ - public void handleCreateReservation(ARMessage message) { + public boolean handleCreateReservation(ARMessage message) { double currentTime = GridSim.clock(); + boolean success; // gets the reservation object and extract some // information from it Reservation reservation = message.getReservation(); - double startTime = reservation.getStartTime(); - int duration = reservation.getDurationTime(); - int reqPE = reservation.getNumPE(); - if(startTime == 0 || startTime < currentTime) - startTime = currentTime; - // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); - sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); - double expTime = Double.NaN; - + // creates a response message to be sent to the requester ARMessage response = message.createResponse(); + // validate the reservation, check num of PEs required, partition, etc. + success = validateReservation(sRes); + + if(!success) { + reservation.setStatus(Reservation.STATUS_FAILED); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return false; + } + + double startTime = reservation.getStartTime(); + if(startTime == 0 || startTime < currentTime) + startTime = currentTime; + + double expTime = Double.NaN; + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- // informs the listeners that a reservation request has arrived @@ -324,24 +335,7 @@ AllocationAction.ITEM_ARRIVED, true, sRes); //---------------------------------------------------------- - - if (reqPE > super.totalPE_) { - String userName = GridSim.getEntityName( message.getSourceID() ); - System.out.println(super.get_name() + ".handleCreateReservation():" + - " Reservation #" + reservation.getID() + " from " + - userName + " user requires " + reservation.getNumPE() + - " PEs from " + startTime + " to " + (startTime + duration)); - System.out.println("--> The resource has only " + - super.totalPE_ + " PEs available."); - - reservation.setStatus(Reservation.STATUS_FAILED); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - sendARMessage(response); - return; - } - boolean success = true; - // if start time = current time, then it is an immediate reservation if(startTime == currentTime) { success = handleImmediateReservation(sRes); @@ -355,9 +349,9 @@ if(!success) { String userName = GridSim.getEntityName( message.getSourceID() ); System.out.println(super.get_name() + ".handleCreateReservation():" + - " Reservation #" + reservation.getID() + " from " + - userName + " user requires " + reservation.getNumPE() + - " PEs from " + startTime + " to " + (startTime + duration)); + " Reservation #" + sRes.getID() + " from " + + userName + " user requires " + sRes.getNumPE() + + " PEs from " + startTime + " to " + sRes.getActualFinishTime()); System.out.println("--> The resource could not handle the reservation."); // Gets availability information and provides it as options @@ -370,7 +364,7 @@ reservation.setReservationOptions(availability); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); sendARMessage(response); - return; + return false; } // if the expiration time is greater than the start time of the @@ -408,13 +402,18 @@ // Informs the listeners about the reservation that has been created GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sRes); + + //---------------------------------------------------------- + return true; } /** * Handles a commit reservation request. * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation has been committed; + * <tt>false</tt> otherwise. */ - public void handleCommitReservation(ARMessage message) { + public boolean handleCommitReservation(ARMessage message) { // gets the reservation id of the message int reservationId = message.getReservationID(); @@ -462,7 +461,7 @@ if(!success) { response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); sendARMessage(response); - return; + return false; } // sets the reservation to committed if it has not been set before @@ -481,28 +480,32 @@ GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_STATUS_CHANGED, true, sRes); - //---------------------------------------------------------- + return true; } /** * Handles a modify reservation request<br> * (NOTE: <b>NOT SUPPORTED YET</b>). * @param message the advance reservation message received. + * @return <tt>false</tt>. */ - public void handleModifyReservation(ARMessage message) { + public boolean handleModifyReservation(ARMessage message) { System.out.println(super.get_name() + ".handleModifyReservation(): not supported at the moment."); + return false; } /** * Handles a cancel reservation request<br> * (NOTE: <b>NOT SUPPORTED YET</b>). * @param message the advance reservation message received. + * @return <tt>false</tt>. */ - public void handleCancelReservation(ARMessage message) { + public boolean handleCancelReservation(ARMessage message) { System.out.println(super.get_name() + ".handleCancelReservation(): not supported at the moment."); + return false; } /** @@ -589,6 +592,41 @@ // --------------------- PROTECTED METHODS ----------------------- /** + * Checks whether the reservation can be handled by the resource. That is, + * verifies if it does not require more resources than what the resource + * can provide and if the corresponding partition can handle the reservation. + * @param res the server side reservation to be examined + * @return <tt>true</tt> if it can be handled; <tt>false</tt> otherwise. + */ + protected boolean validateReservation(SSReservation res) { + int reqPE = res.getNumPE(); + + if (reqPE > super.totalPE_) { + String userName = GridSim.getEntityName( res.getSenderID() ); + System.out.println(super.get_name() + ".validateReservation():" + + " Reservation #" + res.getID() + " from " + + userName + " user requires " + reqPE + + " PEs from " + res.getStartTime() + " to " + res.getActualFinishTime()); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs available."); + return false; + } + + // gets the id of the partition that can handle the reservation + int partitionId = profile_.getCorrespondingPartitionID(res); + if(partitionId == UNKNOWN) { + String userName = GridSim.getEntityName( res.getSenderID() ); + System.out.println(super.get_name() + ".validateReservation():" + + " Reservation #" + res.getID() + " from " + + userName + " cannot be served because no partition can do so."); + return false; + } + + res.setPartitionID(partitionId); + return true; + } + + /** * This method is called to update the schedule. It removes completed * gridlets and return them to the users and verifies whether there are * gridlets in the waiting list that should start execution. It also Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-05-08 07:44:14 UTC (rev 172) @@ -302,29 +302,40 @@ /** * Handles an advance reservation request.<br> * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation has been accepted; + * <tt>false</tt> otherwise. * @pre message != null */ - public void handleCreateReservation(ARMessage message) { + public boolean handleCreateReservation(ARMessage message) { double currentTime = GridSim.clock(); + boolean success; // gets the reservation object and extract some // information from it Reservation reservation = message.getReservation(); - double startTime = reservation.getStartTime(); - int duration = reservation.getDurationTime(); - int reqPE = reservation.getNumPE(); - if(startTime == 0 || startTime < currentTime) - startTime = currentTime; - // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); - sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); - double expTime = Double.NaN; - + // creates a response message to be sent to the requester ARMessage response = message.createResponse(); + // validate the reservation, check num of PEs required, partition, etc. + success = validateReservation(sRes); + + if(!success) { + reservation.setStatus(Reservation.STATUS_FAILED); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return false; + } + + double startTime = reservation.getStartTime(); + if(startTime == 0 || startTime < currentTime) + startTime = currentTime; + + double expTime = Double.NaN; + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- // informs the listeners that a reservation request has arrived @@ -332,24 +343,7 @@ AllocationAction.ITEM_ARRIVED, true, sRes); //---------------------------------------------------------- - - if (reqPE > super.totalPE_) { - String userName = GridSim.getEntityName( message.getSourceID() ); - System.out.println(super.get_name() + ".handleCreateReservation():" + - " Reservation #" + reservation.getID() + " from " + - userName + " user requires " + reservation.getNumPE() + - " PEs from " + startTime + " to " + (startTime + duration)); - System.out.println("--> The resource has only " + - super.totalPE_ + " PEs available."); - - reservation.setStatus(Reservation.STATUS_FAILED); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - sendARMessage(response); - return; - } - boolean success = false; - // if start time = current time, then it is an immediate reservation if(startTime == currentTime) { success = handleImmediateReservation(sRes); @@ -363,9 +357,9 @@ if(!success) { String userName = GridSim.getEntityName( message.getSourceID() ); System.out.println(super.get_name() + ".handleCreateReservation():" + - " Reservation #" + reservation.getID() + " from " + - userName + " user requires " + reservation.getNumPE() + - " PEs from " + startTime + " to " + (startTime + duration)); + " Reservation #" + sRes.getID() + " from " + + userName + " user requires " + sRes.getNumPE() + + " PEs from " + startTime + " to " + sRes.getActualFinishTime()); System.out.println("--> The resource could not handle the reservation."); // Gets availability information and provides it as options @@ -378,7 +372,7 @@ reservation.setReservationOptions(availability); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); sendARMessage(response); - return; + return false; } // if the expiration time is greater than the start time of the @@ -416,13 +410,18 @@ // Informs the listeners about the reservation that has been created GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sRes); + + //---------------------------------------------------------- + return true; } /** * Handles a commit reservation request. * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation has been accepted; + * <tt>false</tt> otherwise. */ - public void handleCommitReservation(ARMessage message) { + public boolean handleCommitReservation(ARMessage message) { // gets the reservation id of the message int reservationId = message.getReservationID(); @@ -470,7 +469,7 @@ if(!success) { response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); sendARMessage(response); - return; + return false; } // sets the reservation to committed if it has not been set before @@ -491,26 +490,31 @@ AllocationAction.ITEM_STATUS_CHANGED, true, sRes); //---------------------------------------------------------- + return true; } /** * Handles a modify reservation request<br> * (NOTE: <b>NOT SUPPORTED YET</b>). * @param message the advance reservation message received. + * @return <tt>false</tt>. */ - public void handleModifyReservation(ARMessage message) { + public boolean handleModifyReservation(ARMessage message) { System.out.println(super.get_name() + ".handleModifyReservation(): not supported at the moment."); + return false; } /** * Handles a cancel reservation request<br> * (NOTE: <b>NOT SUPPORTED YET</b>). * @param message the advance reservation message received. + * @return <tt>false</tt>. */ - public void handleCancelReservation(ARMessage message) { + public boolean handleCancelReservation(ARMessage message) { System.out.println(super.get_name() + ".handleCancelReservation(): not supported at the moment."); + return false; } /** @@ -597,6 +601,41 @@ // --------------------- PROTECTED METHODS ----------------------- /** + * Checks whether the reservation can be handled by the resource. That is, + * verifies if it does not require more resources than what the resource + * can provide and if the corresponding partition can handle the reservation. + * @param res the server side reservation to be examined + * @return <tt>true</tt> if it can be handled; <tt>false</tt> otherwise. + */ + protected boolean validateReservation(SSReservation res) { + int reqPE = res.getNumPE(); + + if (reqPE > super.totalPE_) { + String userName = GridSim.getEntityName( res.getSenderID() ); + System.out.println(super.get_name() + ".validateReservation():" + + " Reservation #" + res.getID() + " from " + + userName + " user requires " + reqPE + + " PEs from " + res.getStartTime() + " to " + res.getActualFinishTime()); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs available."); + return false; + } + + // gets the id of the partition that can handle the reservation + int partitionId = profile_.getCorrespondingPartitionID(res); + if(partitionId == UNKNOWN) { + String userName = GridSim.getEntityName( res.getSenderID() ); + System.out.println(super.get_name() + ".validateReservation():" + + " Reservation #" + res.getID() + " from " + + userName + " cannot be served because no partition can do so."); + return false; + } + + res.setPartitionID(partitionId); + return true; + } + + /** * This method is called to update the schedule. It removes completed * gridlets and return them to the users and verifies whether there are * gridlets in the waiting list that should start execution. It also Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-05-08 07:44:14 UTC (rev 172) @@ -195,9 +195,11 @@ /** * Handles an advance reservation request.<br> * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation was accepted; + * <tt>false</tt> otherwise. * @pre message != null */ - public void handleCreateReservation(ARMessage message) { + public boolean handleCreateReservation(ARMessage message) { double currentTime = GridSim.clock(); // gets the reservation object and extract some @@ -233,7 +235,7 @@ reservation.setStatus(Reservation.STATUS_FAILED); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); sendARMessage(response); - return; + return false; } boolean success = true; @@ -380,16 +382,21 @@ reservation.setReservationOptions(availability); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); sendARMessage(response); + return false; } + + return true; } /** * This method handles a cancel reservation request. * @param message the advance reservation message received requesting * the cancellation + * @return <tt>true</tt> if the reservation was cancelled; + * <tt>false</tt> otherwise. * @pre message != null */ - public void handleCancelReservation(ARMessage message) { + public boolean handleCancelReservation(ARMessage message) { double currentTime = GridSim.clock(); // gets the reservation id of the message @@ -426,7 +433,7 @@ if(!success) { response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); sendARMessage(response); - return; + return false; } boolean inProgress = sRes.getStatus() == Reservation.STATUS_IN_PROGRESS; @@ -461,13 +468,16 @@ // send the response message back to the requester sendARMessage(response); + return true; } /** * Handles a commit reservation request. * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation was committed; + * <tt>false</tt> otherwise. */ - public void handleCommitReservation(ARMessage message) { + public boolean handleCommitReservation(ARMessage message) { double currentTime = GridSim.clock(); @@ -517,7 +527,7 @@ if(!success) { response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); sendARMessage(response); - return; + return false; } // sets the reservation to committed if it has not been set before @@ -538,16 +548,19 @@ AllocationAction.ITEM_STATUS_CHANGED, true, sRes); //---------------------------------------------------------- + return true; } /** * Handles a modify reservation request<br> * (NOTE: <b>NOT SUPPORTED YET</b>). * @param message the advance reservation message received. + * @return <tt>false</tt>. */ - public void handleModifyReservation(ARMessage message) { + public boolean handleModifyReservation(ARMessage message) { System.out.println(super.get_name() + ".handleModifyReservation(): not supported at the moment."); + return false; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2008-05-08 07:44:14 UTC (rev 172) @@ -30,32 +30,40 @@ * A method that handles a new advanced reservation request. * @param message the advance reservation message received requesting * the reservation + * @return <tt>true</tt> if the reservation was accepted; + * <tt>false</tt> otherwise. * @pre message != null */ - void handleCreateReservation(ARMessage message); + boolean handleCreateReservation(ARMessage message); /** * A method that handles a modify reservation request. * @param message the advance reservation message received requesting - * the change + * the change + * @return <tt>true</tt> if the reservation was modified; + * <tt>false</tt> otherwise. * @pre message != null */ - void handleModifyReservation(ARMessage message); + boolean handleModifyReservation(ARMessage message); /** * A method that handles a cancel reservation request. * @param message the advance reservation message received requesting * the cancellation + * @return <tt>true</tt> if the reservation was cancelled; + * <tt>false</tt> otherwise. * @pre message != null */ - void handleCancelReservation(ARMessage message); + boolean handleCancelReservation(ARMessage message); /** * A method that handles a commit reservation request. * @param message the advance reservation message received + * @return <tt>true</tt> if the reservation was committed; + * <tt>false</tt> otherwise. * @pre message != null */ - void handleCommitReservation(ARMessage message); + boolean handleCommitReservation(ARMessage message); /** * A method that handles a query reservation request. Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-05-08 07:44:14 UTC (rev 172) @@ -94,31 +94,23 @@ * or not, <tt>false</tt> otherwise. */ public void gridletSubmit(Gridlet gridlet, boolean ack) { - int reqPE = gridlet.getNumPE(); - - try{ - // reject the Gridlet if it requires more PEs than the resource - // is able to provide - if(reqPE > super.totalPE_){ - String userName = GridSim.getEntityName( gridlet.getUserID() ); - System.out.println(super.get_name() + ".gridletSubmit(): " + - " Gridlet #" + gridlet.getGridletID() + " from " + - userName + " user requires " + gridlet.getNumPE() + " PEs."); - System.out.println("--> The resource has only " + - super.totalPE_ + " PEs."); + // Create a server side Gridlet + SSGridlet sgl = new SSGridlet(gridlet); + boolean success = super.validateGridlet(sgl); + if(!success) { + try { + // reject the Gridlet gridlet.setGridletStatus(Gridlet.FAILED); super.sendFinishGridlet(gridlet); return; } + catch(Exception ex) { + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet"); + return; + } } - catch(Exception ex){ - System.out.println(super.get_name() + - ": Exception on submission of a Gridlet"); - } - // Create a resource Gridlet - SSGridlet sgl = new SSGridlet(gridlet); - //-------------- FOR DEBUGGING PURPOSES ONLY -------------- GridSim.notifyListeners(this.get_id(), @@ -126,29 +118,8 @@ //---------------------------------------------------------- - // the id of the queue where the job can be scheduled - int queueId = profile_.getCorrespondingPartitionID(sgl); - - // if no queue can handle the gridlet, then reject it - if(queueId == UNKNOWN) { - String userName = GridSim.getEntityName( gridlet.getUserID() ); - System.out.println(super.get_name() + ".gridletSubmit(): " + - " Gridlet #" + gridlet.getGridletID() + " from " + - userName + " cannot be handled by any queue in this resource."); - try { - gridlet.setGridletStatus(Gridlet.FAILED); - } catch (Exception ex) { - System.out.println(super.get_name() + - ": Exception on submission of a Gridlet"); - } - super.sendFinishGridlet(gridlet); - return; - } - - sgl.setPartitionID(queueId); - // try to schedule gridlet immediately - boolean success = startGridlet(sgl); + success = startGridlet(sgl); if(!success) { scheduleGridlet(sgl); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-05-08 07:44:14 UTC (rev 172) @@ -100,6 +100,16 @@ // partitions is allowed or not protected boolean allowBorrowing_; + // indicates whether a gridlet should be returned to the user immediately + // if it could not be scheduled to its corresponding partition and the + // borrowing of resources from other partitions is disabled. That is, if + // a gridlet arrives to the resource, the partition does not have enough + // resources, borrowing is disabled and this attribute is true, the gridlet + // will be returned to the user entity. A user may want to change this + // behaviour if he wants to implement manual borrowing or resizing + // of the resource partitions + protected boolean returnGridlet_; + // the number of partitions or queues in this scheduler protected int numPartitions_; @@ -154,6 +164,7 @@ prioritySelector_ = null; lastScheduleUpdate_ = 0.0D; allowBorrowing_ = true; + returnGridlet_ = true; ratingPE_ = 0; } @@ -219,6 +230,28 @@ } /** + * This method is called to specify the behaviour of the policy if a gridlet + * cannot be scheduled to its partition due to the lack of enough resources + * and the borrowing is disabled. If a <tt>true</tt> value is passed to this + * method, it indicates that a gridlet should be returned to the user + * immediately if it could not be scheduled to its corresponding partition + * and the borrowing of resources from other partitions is disabled. That is, + * if a gridlet arrives at the resource, the partition does not have enough + * resources, borrowing is disabled and the returnGridlet behaviour is true, + * the gridlet will be returned to the user entity. This prevents the policy + * from queueing gridlets even if it will never be able to serve them. + * A user may want to change this behaviour if he wants to implement manual + * borrowing or resizing of the resource partitions. In such a case, the + * gridlets will be queued even if they cannot be handled by its partition + * at the time of arrival. + * @param returnGridlet <tt>true</tt> indicates that the gridlet should be + * returned; <tt>false</tt> otherwise. + */ + public void setReturnGridletBehaviour(boolean returnGridlet) { + returnGridlet_ = returnGridlet; + } + + /** * Sets the priority selector to be used by this scheduler. The selector * defines what priorities the scheduler should assign to the gridlets. * @param selector the selector to be used. @@ -339,30 +372,23 @@ * or not, <tt>false</tt> otherwise. */ public void gridletSubmit(Gridlet gridlet, boolean ack) { - int reqPE = gridlet.getNumPE(); - - try { - // reject the Gridlet if it requires more PEs than the resource - // is able to provide - if(reqPE > super.totalPE_){ - String userName = GridSim.getEntityName( gridlet.getUserID() ); - System.out.println(super.get_name() + ".gridletSubmit(): " + - " Gridlet #" + gridlet.getGridletID() + " from " + - userName + " user requires " + gridlet.getNumPE() + " PEs."); - System.out.println("--> The resource has only " + - super.totalPE_ + " PEs."); + // Create a server side Gridlet + SSGridlet sgl = new SSGridlet(gridlet); + boolean success = validateGridlet(sgl); + if(!success) { + try { + // reject the Gridlet gridlet.setGridletStatus(Gridlet.FAILED); super.sendFinishGridlet(gridlet); return; } + catch(Exception ex) { + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet"); + return; + } } - catch(Exception ex) { - System.out.println(super.get_name() + - ": Exception on submission of a Gridlet"); - } - // Create a resource Gridlet - SSGridlet sgl = new SSGridlet(gridlet); if(prioritySelector_ != null) sgl.setPriority(prioritySelector_.getSchedulePriority(sgl)); @@ -373,26 +399,6 @@ //---------------------------------------------------------- - // the id of the queue where the job can be scheduled - int queueId = profile_.getCorrespondingPartitionID(sgl); - - // if no queue can handle the gridlet, then reject it - if(queueId == UNKNOWN) { - String userName = GridSim.getEntityName( gridlet.getUserID() ); - System.out.println(super.get_name() + ".gridletSubmit(): " + - " Gridlet #" + gridlet.getGridletID() + " from " + - userName + " cannot be handled by any queue in this resource."); - try { - gridlet.setGridletStatus(Gridlet.FAILED); - } catch (Exception ex) { - System.out.println(super.get_name() + - ": Exception on submission of a Gridlet"); - } - super.sendFinishGridlet(gridlet); - return; - } - - sgl.setPartitionID(queueId); sgl.setStatus(Gridlet.QUEUED); queuedGridlets_.add(sgl); backfillGridlets(GridSim.clock()); @@ -611,6 +617,61 @@ // -------------------- PROTECTED METHODS ---------------------------- /** + * Checks whether the gridlet can be handled by the resource. That is, + * verifies if it does not require more resources than what the resource + * can provide and if the partition can handle the request. + * @param sgl the server side gridlet to be examined + * @return <tt>true</tt> if it can be handled; <tt>false</tt> otherwise. + */ + protected boolean validateGridlet(SSGridlet sgl) { + int reqPE = sgl.getNumPE(); + + // reject the Gridlet if it requires more PEs than the resource + // is able to provide + if(reqPE > super.totalPE_){ + String userName = GridSim.getEntityName(sgl.getSenderID()); + System.out.println(super.get_name() + ".validateGridlet(): " + + " Gridlet #" + sgl.getID() + " from " + + userName + " user requires " + sgl.getNumPE() + " PEs."); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs."); + return false; + } + + // the id of the queue where the job can be scheduled + int queueId = profile_.getCorrespondingPartitionID(sgl); + + // if no queue can handle the gridlet, then reject it + if(queueId == UNKNOWN) { + String userName = GridSim.getEntityName(sgl.getSenderID()); + System.out.println(super.get_name() + ".validateGridlet(): " + + " Gridlet #" + sgl.getID() + " from " + + userName + " cannot be handled by any partition of this resource."); + return false; + } + // if a partition can serve the gridlet, but it was not given enough + // resources to do so, the borrowing is disabled and the behaviour is + // to return the gridlet in such case, then returns false, forcing + // the gridlet to be returned to the user + else { + QueuePartition partition = profile_.getPartition(queueId); + if(!allowBorrowing_ && returnGridlet_ + && partition.getInitialNumPEs() < reqPE) { + String userName = GridSim.getEntityName(sgl.getSenderID()); + System.out.println(super.get_name() + ".validateGridlet(): " + + " Gridlet #" + sgl.getID() + " from " + + userName + " user requires " + sgl.getNumPE() + " PEs whereas the " + + "partition does not have enough resources and borrowing " + + "is disabled."); + return false; + } + } + + sgl.setPartitionID(queueId); + return true; + } + + /** * Tries to start a gridlet if there are enough processing elements * available at the current simulation time. * @param sgl the gridlet to be started Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-05-08 07:44:14 UTC (rev 172) @@ -261,6 +261,20 @@ } /** + * Gets the idle PEs as a profile entry + * @return the ranges of PEs available at present in all partitions + */ + public MPProfileEntry getIdlePEs() { + MPProfileEntry entry = new MPProfileEntry(GridSim.clock()); + for(QueuePartition queue: queues_.values()) { + PERangeList list = queue.getIdlePERanges() == null ? + null : queue.getIdlePERanges().clone(); + entry.setPERangeList(queue.getPartitionId(), list); + } + return entry; + } + + /** * Checks what PE ranges are available during the given interval. * @param duration the duration of the Gridlet * @return the list of ranges of PEs available Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-05-08 07:44:14 UTC (rev 172) @@ -109,19 +109,22 @@ * @return the string representation */ public String toString() { + if(super.size() == 0) + return "{[]}"; + StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("{"); int index = -1; int last = super.size() - 1; - String delim = ","; for(PERange range : this) { index++; stringBuilder.append(range); - delim = index < last ? delim : "}"; - stringBuilder.append(delim); + if(index < last) + stringBuilder.append(","); } + stringBuilder.append("}"); return stringBuilder.toString(); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java 2008-05-08 07:44:14 UTC (rev 172) @@ -404,6 +404,24 @@ } return result; } + + /** + * Creates a string representation of the reservation for debugging purposes. + * @return a string representation of this reservation. + * @see java.lang.Object#toString() + */ + public String toString(){ + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Reservation={Reservation ID: " + reservID_); + stringBuilder.append(", User ID: " + userID_); + stringBuilder.append(", Status: " + getStatusString(status_)); + stringBuilder.append(", Sub. Time: " + submissionTime_); + stringBuilder.append(", Start Time: " + startTime_); + stringBuilder.append(", FinishTime: " + (startTime_ + duration_)); + stringBuilder.append(", Duration: " + duration_); + stringBuilder.append(", Num. PEs: " + numPE_ + "}"); + return stringBuilder.toString(); + } //------------------------ PRIVATE METHODS ------------------------ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2008-05-08 07:44:14 UTC (rev 172) @@ -157,8 +157,8 @@ catch (Exception ex) { System.out.println(super.get_name() + ": Reservation # " + reservation.getID() + " has not been accepted by "+ - "resource # " + resID + " at time = " + GridSim.clock()); - ex.printStackTrace(); + "resource # " + resID + " at time = " + GridSim.clock() + + ", exception=" + ex.getMessage()); reservation = null; } return reservation; @@ -545,10 +545,11 @@ } /** - * Sends a reservation message. + * Sends a reservation message. This message is protected in case + * the user wants to change it to not consider network delay, for example. * @param message the message to be sent */ - private void sendARMessage(ARMessage message) { + protected void sendARMessage(ARMessage message) { // send message to the destination super.send(message.getDestinationID(), GridSimTags.SCHEDULE_NOW, message.getMessageType(), message); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-04-28 06:23:28 UTC (rev 171) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-05-08 07:44:14 UTC (rev 172) @@ -167,7 +167,8 @@ * @post $none */ protected double forecastExecutionTime(double availableRating, double length){ - double finishTime = (length / availableRating); + double finishTime = (length / availableRating); + finishTime = (long)(finishTime + 1); // This is as a safeguard since the finish time can be extremely // small close to 0.0, such as 4.5474735088646414E-14. Hence causing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-28 06:23:55
|
Revision: 171 http://gridsim.svn.sourceforge.net/gridsim/?rev=171&view=rev Author: marcos_dias Date: 2008-04-27 23:23:28 -0700 (Sun, 27 Apr 2008) Log Message: ----------- Bug fix, a job would not start if the reservation was made for the exact runtime estimate of the job. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-04-16 10:39:27 UTC (rev 170) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-04-28 06:23:28 UTC (rev 171) @@ -220,7 +220,7 @@ } // check whether the gridlet is expected to run for longer than // the time previously reserved - else if (executionTime >= sRes.getDurationTime()) { + else if (executionTime > sRes.getDurationTime()) { String userName = GridSim.getEntityName( gridlet.getUserID() ); System.out.println(super.get_name() + ".gridletSubmit(): " + " Gridlet #" + gridlet.getGridletID() + " from " + Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-04-16 10:39:27 UTC (rev 170) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-04-28 06:23:28 UTC (rev 171) @@ -228,7 +228,7 @@ } // check whether the gridlet is expected to run for longer than // the time previously reserved - else if (executionTime >= sRes.getDurationTime()) { + else if (executionTime > sRes.getDurationTime()) { String userName = GridSim.getEntityName( gridlet.getUserID() ); System.out.println(super.get_name() + ".gridletSubmit(): " + " Gridlet #" + gridlet.getGridletID() + " from " + Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-04-16 10:39:27 UTC (rev 170) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-04-28 06:23:28 UTC (rev 171) @@ -715,13 +715,13 @@ } // check whether the gridlet is expected to run for longer than // the time previously reserved - else if (executionTime >= sRes.getDurationTime()) { + else if (executionTime > sRes.getDurationTime()) { String userName = GridSim.getEntityName( gridlet.getUserID() ); System.out.println(super.get_name() + ".gridletSubmit(): " + " Gridlet #" + gridlet.getGridletID() + " from " + userName + " cannot be accepted because the reservation #" + - sRes.getID() + " is for " + sRes.getDurationTime() + - " while the gridlet is expected to run for " + + sRes.getID() + " is for " + sRes.getDurationTime() + " seconds," + + " whereas the gridlet is expected to run for " + executionTime + " seconds."); success = false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-16 10:39:21
|
Revision: 170 http://gridsim.svn.sourceforge.net/gridsim/?rev=170&view=rev Author: marcos_dias Date: 2008-04-16 03:39:27 -0700 (Wed, 16 Apr 2008) Log Message: ----------- + Option to get free time slots from AvailabilityInfo object. + Changes in the java doc comments. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/util/Workload.java Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-04-16 10:39:27 UTC (rev 170) @@ -8,6 +8,7 @@ import eduni.simjava.Sim_event; import eduni.simjava.Sim_system; +import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; import gridsim.IO_data; @@ -230,16 +231,10 @@ // create the gridlet int len = runTime * rating_; // calculate a job length for each PE - Gridlet gl = new Gridlet(id, len, size_, size_); + Gridlet gl = new Gridlet(id, len, size_, size_, GridSim.isTraceEnabled()); gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - // check the submit time if (submitTime < 0) { submitTime = 0; Modified: branches/gridsim4.0-branch3/source/gridsim/Gridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/Gridlet.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/Gridlet.java 2008-04-16 10:39:27 UTC (rev 170) @@ -1199,7 +1199,7 @@ // Creates the history or transactions of this Gridlet newline_ = System.getProperty("line.separator"); num_ = new DecimalFormat("#0.00#"); // with 3 decimal spaces - history_ = new StringBuffer(1000); + history_ = new StringBuffer(500); history_.append("Time below denotes the simulation time."); history_.append( System.getProperty("line.separator") ); history_.append("Time (sec) Description Gridlet #"+gridletID_); Modified: branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-04-16 10:39:27 UTC (rev 170) @@ -215,8 +215,9 @@ // Creates a thread that will be responsible for starting the simulation // I don't want to block the buttons during the whole simulation because // they will be required for other things - simThread_ = new Thread(){ - public void run(){ + simThread_ = new Thread() { + public void run() { + this.setName("Simulation"); // here in fact, start the simulation GridSim.startGridSimulation(); } Modified: branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-04-16 10:39:27 UTC (rev 170) @@ -153,7 +153,7 @@ /** * Returns the font to be used in the graphs - * @return + * @return the font to be used in the graphs */ public Font getGraphFont() { return graphFont; @@ -186,6 +186,62 @@ } /** + * Return the colours to be used for the partitions + * @return the colors for the partitions + */ + public Color[] getQueueColors() { + return this.colorQueues; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getJobQueuedColors() { + return this.colorQueued; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getJobDoneColors() { + return this.colorDone; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getJobInExecColors() { + return this.colorInExec; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getARNonCommittedColors() { + return this.colorARNonCommitted; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getARCommittedColors() { + return this.colorARCommitted; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getARInProgressColors() { + return this.colorARInProgress; + } + + /** * Creates a colour palette * @return the colour palette */ @@ -242,60 +298,4 @@ return colors; } - - /** - * Return the colours to be used for the partitions - * @return the colors for the partitions - */ - public Color[] getQueueColors() { - return this.colorQueues; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getJobQueuedColors() { - return this.colorQueued; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getJobDoneColors() { - return this.colorDone; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getJobInExecColors() { - return this.colorInExec; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getARNonCommittedColors() { - return this.colorARNonCommitted; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getARCommittedColors() { - return this.colorARCommitted; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getARInProgressColors() { - return this.colorARInProgress; - } } Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-04-16 10:39:27 UTC (rev 170) @@ -691,7 +691,7 @@ x = SHIFT_X - 5; y = heightGph + SHIFT_Y - 10; g2D.rotate(-1.571, x, y); - g2D.drawString("Processing Elements", x, y); + g2D.drawString(" Processing Elements: " + numPE_, x, y); g2D.rotate(1.571, x, y); g2D.setColor(ctLineColor_); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-04-16 10:39:27 UTC (rev 170) @@ -383,7 +383,73 @@ return true; } + + /** + * Returns the scheduling options, or time slots contained in this + * availability information object within a specified period of time. <br> + * <b>NOTE:</b> The time slots returned by this method <b>OVERLAP</b> because + * they are not the scheduling options for jobs. + * @param startTime the start time of the period. + * @param finishTime the finish time of the period. + * @return a linked list with the time slots contained in this availability + * information object within a specified period of time. + */ + public LinkedList<TimeSlot> getSchedulingOptions(double startTime, double finishTime) { + LinkedList<TimeSlot> slots = new LinkedList<TimeSlot>(); + // start time cannot be smaller than the start time of the info obj + if(startTime < startTime_) + startTime = startTime_; + + // start time cannot be larger than the finish time of the info obj + if(startTime > finishTime_) { + return slots; + } + + AvailabilityInfoEntry entry = getPrecedingEntry(startTime); + AvailabilityInfoEntry nextEntry = null; + PERangeList slotRanges = null; + PERangeList intersect = null; + int size = super.size(); + + for(int i=super.indexOf(entry); i<size; i++) { + entry = super.get(i); + if(entry.getTime() >= finishTime) { + break; + } + else if (entry.getNumPE() == 0) { + continue; + } + + double slotStart = + entry.getTime() < startTime ? startTime : entry.getTime(); + slotRanges = entry.getAvailRanges(); + + for(int j=i; j<size; j++) { + nextEntry = super.get(j); + intersect = PERangeList.intersection(slotRanges, nextEntry.getAvailRanges()); + double endTime = entry.getTime(); + boolean different = !intersect.equals(slotRanges); + if(j < (size-1) && different) { + TimeSlot slot = new TimeSlot(slotStart, endTime, slotRanges); + slots.add(slot); + slotRanges = intersect; + } + else if (j == (size-1)) { + TimeSlot slot = new TimeSlot(slotStart, finishTime, slotRanges); + slots.add(slot); + continue; + } + + if(intersect == null && intersect.getNumPE() == 0) { + break; + } + } + } + + return slots; + } + /** * Returns the time slots contained in this availability information object * within a specified period of time. <br> Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-04-16 10:39:27 UTC (rev 170) @@ -104,26 +104,27 @@ } } - /** + /** * Creates an String representation of this list * @return the string representation */ public String toString() { - String result = "{"; - boolean first = true; - for(PERange range : this){ - if(!first){ - result += "," + range; - } - else{ - first = false; - result += range; - } + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("{"); + int index = -1; + int last = super.size() - 1; + String delim = ","; + + for(PERange range : this) { + index++; + stringBuilder.append(range); + delim = index < last ? delim : "}"; + stringBuilder.append(delim); } - result += "}"; - return result; + + return stringBuilder.toString(); } - + /** * Checks whether this list is equals to the list provided * @param list the list to compare this list against @@ -266,6 +267,10 @@ */ public static PERangeList selectPERangeList(int reqPE, PERangeList ranges){ PERangeList selected = new PERangeList(); + + if(ranges == null) + return null; + try{ ranges.sortRanges(); for(PERange range: ranges){ @@ -282,7 +287,8 @@ } } catch(Exception ex){ - ex.printStackTrace(); + System.out.println("PERangeList.selectPERangeList(): Exception: " + + ex.getMessage()); selected = null; } @@ -492,9 +498,11 @@ return false; } -// // FOR DEBUGGING PURPOSES ONLY... +//// // FOR DEBUGGING PURPOSES ONLY... // public static void main(String args[]){ // +// double start = System.currentTimeMillis(); +// // PERange ra = new PERange(0, 10); // PERange rb = new PERange(11, 20); // PERange rc = new PERange(21, 30); @@ -517,10 +525,13 @@ // // PERangeList list3 = new PERangeList(); // list3.add(new PERange(500, 2000)); -//// list3.add(new PERange(0, 499)); -//// list3.add(new PERange(1001, 1005)); +// list3.add(new PERange(0, 499)); +// list3.add(new PERange(1001, 1005)); // // PERangeList difference = symmetricDifference(list1, list3); // System.out.println("Symmetric difference between list " + list1 + " and " + list3 + " is " + difference); +// +// double finish = System.currentTimeMillis(); +// System.out.println("Time taken = " + (finish - start)); // } } \ No newline at end of file Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-04-16 10:39:27 UTC (rev 170) @@ -504,7 +504,7 @@ * Creates a String representation of this Gridlet * for debugging purposes */ - public String toString(){ + public String toString() { String result = "Gridlet {id=" + getID() + ", start time=" + startTime_ + ", expected finish time=" + expectedFinishTime_ + @@ -523,26 +523,23 @@ * @see GridSimVisualizer#TIME_UNIT_HOUR */ public String toString(int timeUnit){ - String timeDescr = getTimeDescr(timeUnit); - return "Gridlet ID: " + gridlet_.getGridletID() + "\n" + - "User ID: " + gridlet_.getUserID() + "\n" + - "Status: " + Gridlet.getStatusString(gridlet_.getGridletStatus()) + "\n" + - "Sub. Time: " + decFormater_.format(convertTime(getSubmissionTime(), timeUnit)) + - " " + timeDescr + "\n" + - "Start Time: " + decFormater_.format(convertTime(startTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Exp. Finish Time: " + decFormater_.format(convertTime(expectedFinishTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Finish Time: " + decFormater_.format(convertTime(actualFinishTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Duration: " + decFormater_.format(convertTime(actualFinishTime_ - startTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Length: " + decFormater_.format(gridlet_.getGridletLength()) + " MIs" + "\n" + - "Num. PEs: " + numPE_; + String timeDescr = " " + getTimeDescr(timeUnit); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Gridlet ID: " + gridlet_.getGridletID()); + stringBuilder.append("\nUser ID: " + gridlet_.getUserID()); + stringBuilder.append("\nStatus: " + Gridlet.getStatusString(gridlet_.getGridletStatus())); + stringBuilder.append("\nSub. Time: " + formatTime(getSubmissionTime(), timeUnit) + timeDescr); + stringBuilder.append("\nStart Time: " + formatTime(startTime_, timeUnit) + timeDescr); + stringBuilder.append("\nExp. Finish Time: " + formatTime(expectedFinishTime_, timeUnit) + timeDescr); + stringBuilder.append("\nFinish Time: " + formatTime(actualFinishTime_, timeUnit) + timeDescr); + stringBuilder.append("\nDuration: " + formatTime(actualFinishTime_ - startTime_, timeUnit) + timeDescr); + stringBuilder.append("\nLength: " + gridlet_.getGridletLength() + " MIs"); + stringBuilder.append("\nNum. PEs: " + numPE_); + return stringBuilder.toString(); } // -------------------- PRIVATE METHODS --------------------- - + /** * Initialises all local attributes * @pre $none @@ -591,10 +588,11 @@ /** * Converts the time to the time unit in use * @param the time in seconds + * @param timeUnit the time unit id * @return the time in the unit in use */ - private double convertTime(double time, int timeUnit) { - return time / timeUnit; + private String formatTime(double time, int timeUnit) { + return decFormater_.format(time / timeUnit); } } // end class Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2008-04-16 10:39:27 UTC (rev 170) @@ -402,20 +402,17 @@ * @see GridSimVisualizer#TIME_UNIT_HOUR */ public String toString(int timeUnit) { - String unitDesc = getTimeDescr(timeUnit); - String result = "Reservation ID: " + reservation_.getID() + "\n" + - "User ID: " + getSenderID() + "\n" + - "Status: " + Reservation.getStatusString(reservation_.getStatus()) + "\n" + - "Sub. Time: " + decFormater_.format(convertTime(getSubmissionTime(), timeUnit)) + - " " + unitDesc + "\n" + - "Start Time: " + decFormater_.format(convertTime(reservation_.getStartTime(), timeUnit)) + - " " + unitDesc + "\n" + - "FinishTime: " + decFormater_.format(convertTime(getActualFinishTime(), timeUnit)) + - " " + unitDesc + "\n" + - "Duration: " + decFormater_.format(convertTime(reservation_.getDurationTime(), timeUnit)) + - " " + unitDesc + "\n" + - "Num. PEs: " + reservation_.getNumPE(); - return result; + String timeDescr = " " + getTimeDescr(timeUnit); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Reservation ID: " + reservation_.getID()); + stringBuilder.append("\nUser ID: " + getSenderID()); + stringBuilder.append("\nStatus: " + Reservation.getStatusString(reservation_.getStatus())); + stringBuilder.append("\nSub. Time: " + formatTime(getSubmissionTime(), timeUnit) + timeDescr); + stringBuilder.append("\nStart Time: " + formatTime(reservation_.getStartTime(), timeUnit) + timeDescr); + stringBuilder.append("\nFinishTime: " + formatTime(getActualFinishTime(), timeUnit) + timeDescr); + stringBuilder.append("\nDuration: " + formatTime(reservation_.getDurationTime(), timeUnit) + timeDescr); + stringBuilder.append("\nNum. PEs: " + reservation_.getNumPE()); + return stringBuilder.toString(); } /** @@ -448,10 +445,11 @@ /** * Converts the time to the time unit in use * @param the time in seconds + * @param timeUnit the time unit id * @return the time in the unit in use */ - private static double convertTime(double time, int timeUnit) { - return time / timeUnit; + private String formatTime(double time, int timeUnit) { + return decFormater_.format(time / timeUnit); } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-04-16 10:39:27 UTC (rev 170) @@ -150,7 +150,8 @@ } } catch(Exception ex){ - System.out.println(super.get_name() + ".selectPERangeList(): Exception: " + ex.getMessage()); + System.out.println(super.get_name() + + ".selectPERangeList(): Exception: " + ex.getMessage()); } return selected; } Modified: branches/gridsim4.0-branch3/source/gridsim/util/Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/util/Workload.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/util/Workload.java 2008-04-16 10:39:27 UTC (rev 170) @@ -90,7 +90,6 @@ private int MAX_FIELD; // max number of field in the trace file private String COMMENT; // a string that denotes the start of a comment private final int IRRELEVANT = -1; // irrelevant number - protected final int INTERVAL = 10; // number of intervals private String[] fieldArray_; // a temp array storing all the fields /** @@ -503,7 +502,9 @@ } boolean success = false; - + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + // read the gz file if (fileName_.endsWith(".gz") == true) { success = readGZIPFile(fileName_); @@ -516,6 +517,9 @@ else { success = readFile(fileName_); } + + // help the garbage collector + fieldArray_ = null; // if all the gridlets have been submitted if (success == true) { @@ -741,13 +745,6 @@ gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) - { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - // check the submit time if (submitTime < 0) { submitTime = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-11 00:58:19
|
Revision: 169 http://gridsim.svn.sourceforge.net/gridsim/?rev=169&view=rev Author: marcos_dias Date: 2008-04-10 17:58:22 -0700 (Thu, 10 Apr 2008) Log Message: ----------- Changes in the easy backfilling policy when it uses only one pivot. If we avoid creating a list of pivots the simulations are around 30% faster. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/MAUIEBParallelSpaceShared.java Modified: branches/gridsim4.0-branch3/source/gridsim/GridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-04-09 01:48:26 UTC (rev 168) +++ branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-04-11 00:58:22 UTC (rev 169) @@ -17,6 +17,7 @@ import gridsim.turbo.EBParallelSpaceShared; import gridsim.turbo.CBParallelSpaceShared; import gridsim.turbo.EBMultiplePartitions; +import gridsim.turbo.MAUIEBParallelSpaceShared; import gridsim.turbo.TResourceCharacteristics; import gridsim.index.*; @@ -643,6 +644,10 @@ policy_ = new EBParallelSpaceShared(super.get_name(), "EBParallelSpaceShared"); break; + case TResourceCharacteristics.MAUI_EB_PARALLEL_SPACE_SHARED: + policy_ = new MAUIEBParallelSpaceShared(super.get_name(), "MAUIEBParallelSpaceShared"); + break; + case TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED: policy_ = new ARParallelSpaceShared(super.get_name(), "ARParallelSpaceShared"); break; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-04-09 01:48:26 UTC (rev 168) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-04-11 00:58:22 UTC (rev 169) @@ -1056,7 +1056,6 @@ double potStartTime = -1; // keep the potential start time of the gridlet double potFinishTime = -1; // store the gridlet's expected finish time - intersectList = null; int length = availProfile_.size(); Iterator<AvailabilityProfileEntry> iterProfile = availProfile_.iterator(); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-04-09 01:48:26 UTC (rev 168) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-04-11 00:58:22 UTC (rev 169) @@ -11,26 +11,19 @@ import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; -import gridsim.ParameterException; import gridsim.gui.AllocationAction; import java.util.Calendar; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedList; /** * <tt>EBParallelSpaceShared</tt> class is an allocation policy for * <tt>GridResource</tt> that implements aggressive backfilling (EASY). * The policy is based the aggressive backfilling algorithm described in the - * following papers: + * following paper: * <p> * <ul> - * <li> David B. Jackson, Quinn Snell and Mark J. Clement. Core Algorithms - * of the Maui Scheduler, Revised Papers from the 7th International - * Workshop on Job Scheduling Strategies for Parallel Processing - * (JSSPP '01), Lecture Notes in Computer Science, pp. 87-102, London, UK. - * * <li>Ahuva W. Mu'alem and Dror G. Feitelson, Utilization, Predictability, * Workloads, and User Runtime Estimates in Scheduling the IBM SP2 * with Backfilling. IEEE Transactions on Parallel and Distributed @@ -38,14 +31,7 @@ * </ul> * <br> This policy maintains an availability profile. The availability * profile contains information about the ranges of processing elements - * (PEs) that will be released when the running jobs complete. The aggressive - * backfilling implemented here is similar to that used by the MAUI scheduler. - * That is, you can set the max number of pivot jobs will be considered during - * backfilling. A job will be used to backfill if it does not delay the first - * 'max number of pivots' in the queue. By default, only one pivot job is - * used. You can set that by invoking {@link #setMaximumNumberOfPivots(int)}. - * This scheduler will behave like conservative backfilling when the number - * of pivots is very large. + * (PEs) that will be released when the running jobs complete. * <p> * <b>LIMITATIONS:</b><br> * <ul> @@ -71,15 +57,15 @@ public class EBParallelSpaceShared extends CBParallelSpaceShared { - // Pivot jobs (i.e. the first n jobs in the queue) - protected LinkedList<SSGridlet> pivotGridlets_; + // Pivot job (i.e. the first job in the queue) + protected SSGridlet pivot_; - // Similarly to the aggressive backfilling in MAUI, the user - // can specify how many pivots can be considered when scheduling a job. - // That is, a job can be used to backfill if it does not delay the - // first maxPivots_ jobs in the waiting queue. If this parameter is - // very large, the policy will behave like conservative backfilling - private int maxPivots_; + // the time when the first job in the waiting queue can start execution + private double shadowTime_; + + // the list of PEs left unused when the first job in the waiting + // queue is scheduled + private PERangeList extraPEs_; /** * Allocates a new <tt>EBParallelSpaceShared</tt> object @@ -105,68 +91,20 @@ String entityName) throws Exception{ super(resourceName, entityName); // initialises local variables - pivotGridlets_ = new LinkedList<SSGridlet>(); - maxPivots_ = 1; // default number of pivots is one + shadowTime_ = Double.MAX_VALUE; + extraPEs_ = null; + pivot_ = null; } /** - * Allocates a new <tt>EBParallelSpaceShared</tt> object - * - * @param resourceName the <tt>GridResource</tt> entity name that will - * contain this allocation policy - * @param entityName this object entity name - * @param maxNumPivots the maximum number of pivots used by this scheduler - * @throws Exception This happens when one of the following scenarios occur: - * <ul> - * <li> Creating this entity before initialising GridSim package - * <li> The entity name is <tt>null</tt> or empty - * <li> The entity has <tt>zero</tt> number of PEs (Processing - * Elements). <br> - * No PEs, which means that the Gridlets cannot be processed. - * A GridResource must contain one or more Machines. - * A Machine must contain one or more PEs. - * <li> The maximum number of pivots is <= 0. - * </ul> - * - * @see gridsim.GridSim#init(int, Calendar, boolean, - * String[], String[], String) - */ - public EBParallelSpaceShared(String resourceName, String entityName, - int maxNumPivots) throws Exception{ - this(resourceName, entityName); - if(!setMaximumNumberOfPivots(maxNumPivots)) { - throw new ParameterException("Maximum number of pivots should be > 0."); - } - } - - /** * Handles internal events that come to this entity. */ public void body() { super.body(); - - // resets variables to default values - pivotGridlets_.clear(); + shadowTime_ = Double.MAX_VALUE; + extraPEs_ = null; + pivot_ = null; } - - /** - * Sets the maximum number of pivot jobs. Similarly to the aggressive - * backfilling in MAUI, the system administrator can specify how many - * pivots can be considered when scheduling a job. That is, a job can - * be used to backfill if it does not delay the first maxPivots jobs - * in the waiting queue. If this parameter is very large, the policy - * will behave like conservative backfilling - * @param maxPivots the maximum number of pivots - * @return <tt>true</tt> if the number of pivots has been set; - * <tt>false</tt> otherwise. - */ - public boolean setMaximumNumberOfPivots(int maxPivots) { - if(maxPivots < 1) - return false; - - maxPivots_ = maxPivots; - return true; - } /** * Schedules/adds to the queue a new <tt>Gridlet</tt> received by the @@ -292,8 +230,9 @@ // if start time has been set, then it means that gridlet is // a pivot. So, we need to remove it from the pivot list - if(sgl.getStartTime() > 0) { - pivotGridlets_.remove(sgl); + if(sgl == pivot_) { + pivot_ = null; + shadowTime_ = Double.MAX_VALUE; updateProfile = true; } } @@ -398,11 +337,11 @@ protected boolean scheduleGridlet(SSGridlet sgl) { // if there are enough pivots already, then just return - if(pivotGridlets_.size() >= maxPivots_) + if(pivot_ != null) return false; - super.enqueueGridlet(sgl); - pivotGridlets_.add(sgl); + enqueueGridlet(sgl); + pivot_ = sgl; //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- @@ -416,6 +355,41 @@ } /** + * Enqueues a gridlet. That is, finds the anchor point, which is the point + * in the availability profile where there are enough processors to execute + * the Gridlet, and calculates the extra PEs and shadow time accordingly. + * @param sgl the resource gridlet + */ + protected void enqueueGridlet(SSGridlet sgl){ + + // calculate the execution time of the Gridlet + double executionTime = + super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); + + // check whether there are PEs available over the time interval requested + Object[] availObj = checkPERangesAvailability(sgl.getNumPE(), executionTime); + + // the anchor index, the entry in the profile where the gridlet will be placed + int anchorIndex = (Integer)availObj[0]; + PERangeList selected = (PERangeList)availObj[2]; + + // a pointer to the anchor entry + AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); + double startTime = anchorEntry.getTime(); + double finishTime = startTime + executionTime; + shadowTime_ = startTime; + extraPEs_ = PERangeList.difference(anchorEntry.getPERanges(), selected); + + // Set the list of ranges used by the gridlet + sgl.setPERangeList(selected); + + // change Gridlet status + sgl.setStatus(Gridlet.QUEUED); + sgl.setStartTime(startTime); + sgl.setActualFinishTime(finishTime); + } + + /** * This method is called to update the schedule. It removes completed * gridlets and return them to the users and verifies whether the first gridlet * in the waiting queue can be started. If it cannot be started, them @@ -424,8 +398,8 @@ */ protected void updateSchedule() { int itemsFinished = 0; + int itemsStarted = 0; double currentTime = GridSim.clock(); - int itemsStarted = 0; itemsFinished = finishRunningGridlets(currentTime); @@ -456,26 +430,34 @@ protected int backfillGridlets(double currentTime) { int gridletStarted = 0; - // checks the pivots first - Iterator<SSGridlet> iter = pivotGridlets_.iterator(); - while(iter.hasNext()) { - SSGridlet pivot = iter.next(); - if(pivot.getStartTime() <= currentTime) { - gridletStarted++; - queuedGridlets_.remove(pivot); - runningGridlets_.add(pivot); - // change Gridlet status - pivot.setStatus(Gridlet.INEXEC); - super.sendInternalEvent(pivot.getActualFinishTime()-currentTime, + // checks the pivot first + if(pivot_ != null && pivot_.getStartTime() <= currentTime) { + gridletStarted++; + queuedGridlets_.remove(pivot_); // pivots should be at the beginning + runningGridlets_.add(pivot_); + + // a pointer to the last entry analysed + AvailabilityProfileEntry tailEntry = + availProfile_.getPrecedingEntry(pivot_.getActualFinishTime()); + + int tailIndex = tailEntry == null ? -1 : availProfile_.indexOf(tailEntry); + + // allocate the ranges of PEs to the gridlet + allocateImmediatePERanges(tailIndex, pivot_.getPERangeList(), + currentTime, pivot_.getActualFinishTime()); + + // change Gridlet status + pivot_.setStatus(Gridlet.INEXEC); + super.sendInternalEvent(pivot_.getActualFinishTime()-currentTime, UPDATE_SCHEDULE_TAG); - iter.remove(); + pivot_ = null; + shadowTime_ = Double.MAX_VALUE; - //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- - GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); - //---------------------------------------------------------- - } + //---------------------------------------------------------- } // order jobs according to the ordering heuristic provided. @@ -484,12 +466,17 @@ Collections.sort(queuedGridlets_, super.jobOrderHeuristic_); // Start the execution of Gridlets that are queued - iter = queuedGridlets_.iterator(); + Iterator<SSGridlet >iter = queuedGridlets_.iterator(); while (iter.hasNext()) { + // to prevent the policy from iterating the list unnecessarily + if(resource_.getNumFreePE() == 0 && pivot_ != null) { + break; + } + SSGridlet gridlet = iter.next(); if(gridlet.getStartTime() > 0) continue; - + boolean success = startGridlet(gridlet); // if the job could not be scheduled immediately, then enqueue it @@ -515,6 +502,98 @@ return gridletStarted; } + /** + * Allocates a Gridlet into free PEs, sets the Gridlet status to INEXEC, + * updates the availability profile and the ranges currently available. + * @param sgl a SSGridlet object + * @return <tt>true</tt> if one of the two following conditions + * holds true: + * <ul> + * <li> There are currently free PE to process the Gridlet and the Gridlet + * WILL NOT execute beyond the <b>shadow time</b>. That is, it + * WILL NOT delay the first gridlet in the waiting queue. + * <li> There are currently free PE to process the Gridlet, the Gridlet + * WILL execute beyond the <b>shadow time</b> but WILL NOT use more + * PEs than those left as <b>extra nodes<b>. That is, nodes remaining + * idle when the first gridlet in the waiting queue starts. + * </ul> + * <br> + * The method returns <tt>false</tt> otherwise. + * @pre sgl != null + * @post $none + */ + protected boolean startGridlet(SSGridlet sgl) { + int reqPE = sgl.getNumPE(); + + if(resource_.getNumFreePE() < reqPE) { + return false; + } + + // calculate the execution time of the Gridlet + double executionTime = + super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); + + // calculates how much ahead to look into the availability profile + double currentTime = GridSim.clock(); + + // the Gridlet's expected finish time + double finishTime = currentTime + executionTime; + + PERangeList intersect = resource_.getFreePERanges(); + if(finishTime > shadowTime_) + intersect = PERangeList.intersection(intersect, extraPEs_); + + // the list of ranges of PEs selected for the gridlet + PERangeList selected = super.selectPERangeList(reqPE, intersect); + if(selected == null || selected.getNumPE() < reqPE) { + return false; + } + + // tail index represents the position which corresponds to the closest + // entry to the gridlet's finish time OR an existing entry whose + // time is equals to the gridlet's or advance reservation's finish time + int tailIndex = -1; + + // a pointer to the last entry analysed + AvailabilityProfileEntry tailEntry = + availProfile_.getPrecedingEntry(finishTime); + + tailIndex = tailEntry == null ? -1 : availProfile_.indexOf(tailEntry); + + // allocate the ranges of PEs to the gridlet + allocateImmediatePERanges(tailIndex, selected, currentTime, finishTime); + + if(finishTime > shadowTime_) { + extraPEs_ = PERangeList.difference(extraPEs_, selected); + } + + // add this Gridlet into execution list + runningGridlets_.add(sgl); + sgl.setStartTime(currentTime); + sgl.setActualFinishTime(finishTime); + + // change Gridlet status + sgl.setStatus(Gridlet.INEXEC); + + // Sets the list of ranges used by the gridlet + sgl.setPERangeList(selected); + + // then send this event to itself to update the queues after + // this gridlet's completion time + super.sendInternalEvent(executionTime, UPDATE_SCHEDULE_TAG); + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + + return true; + } + // ------------------------- PRIVATE METHODS ---------------------------- /** Added: branches/gridsim4.0-branch3/source/gridsim/turbo/MAUIEBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MAUIEBParallelSpaceShared.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MAUIEBParallelSpaceShared.java 2008-04-11 00:58:22 UTC (rev 169) @@ -0,0 +1,553 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + */ + +package gridsim.turbo; + +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.ParameterException; +import gridsim.gui.AllocationAction; + +import java.util.Calendar; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; + +/** + * <tt>EBParallelSpaceShared</tt> class is an allocation policy for + * <tt>GridResource</tt> that implements aggressive backfilling (EASY). + * The policy is based the aggressive backfilling algorithm described in the + * following papers: + * <p> + * <ul> + * <li> David B. Jackson, Quinn Snell and Mark J. Clement. Core Algorithms + * of the Maui Scheduler, Revised Papers from the 7th International + * Workshop on Job Scheduling Strategies for Parallel Processing + * (JSSPP '01), Lecture Notes in Computer Science, pp. 87-102, London, UK. + * + * <li>Ahuva W. Mu'alem and Dror G. Feitelson, Utilization, Predictability, + * Workloads, and User Runtime Estimates in Scheduling the IBM SP2 + * with Backfilling. IEEE Transactions on Parallel and Distributed + * Systems, 12:(6), pp. 529-543, 2001. + * </ul> + * <br> This policy maintains an availability profile. The availability + * profile contains information about the ranges of processing elements + * (PEs) that will be released when the running jobs complete. The aggressive + * backfilling implemented here is similar to that used by the MAUI scheduler. + * That is, you can set the max number of pivot jobs will be considered during + * backfilling. A job will be used to backfill if it does not delay the first + * 'max number of pivots' in the queue. By default, only one pivot job is + * used. You can set that by invoking {@link #setMaximumNumberOfPivots(int)}. + * This scheduler will behave like conservative backfilling when the number + * of pivots is very large. + * <p> + * <b>LIMITATIONS:</b><br> + * <ul> + * <li> The list of machines comprising this resource must be + * homogeneous. + * <li> Local load is not considered. If you would like to + * simulate this, you have to model the local load as gridlets. + * It is more precise and faster. To do so, please check + * {@link Lublin99Workload}. + * <li> Gridlets cannot be paused nor migrated. + * </ul> + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.turbo.TAllocPolicy + * @see gridsim.turbo.CBParallelSpaceShared + * @see gridsim.turbo.PERange + * @see gridsim.turbo.PERangeList + */ + +public class MAUIEBParallelSpaceShared extends CBParallelSpaceShared { + + // Pivot jobs (i.e. the first n jobs in the queue) + protected LinkedList<SSGridlet> pivotGridlets_; + + // Similarly to the aggressive backfilling in MAUI, the user + // can specify how many pivots can be considered when scheduling a job. + // That is, a job can be used to backfill if it does not delay the + // first maxPivots_ jobs in the waiting queue. If this parameter is + // very large, the policy will behave like conservative backfilling + private int maxPivots_; + + /** + * Allocates a new <tt>EBParallelSpaceShared</tt> object + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * + * @see gridsim.GridSim#init(int, Calendar, boolean, + * String[], String[], String) + */ + public MAUIEBParallelSpaceShared(String resourceName, + String entityName) throws Exception{ + super(resourceName, entityName); + // initialises local variables + pivotGridlets_ = new LinkedList<SSGridlet>(); + maxPivots_ = 1; // default number of pivots is one + } + + /** + * Allocates a new <tt>EBParallelSpaceShared</tt> object + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @param maxNumPivots the maximum number of pivots used by this scheduler + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource must contain one or more Machines. + * A Machine must contain one or more PEs. + * <li> The maximum number of pivots is <= 0. + * </ul> + * + * @see gridsim.GridSim#init(int, Calendar, boolean, + * String[], String[], String) + */ + public MAUIEBParallelSpaceShared(String resourceName, String entityName, + int maxNumPivots) throws Exception{ + this(resourceName, entityName); + if(!setMaximumNumberOfPivots(maxNumPivots)) { + throw new ParameterException("Maximum number of pivots should be > 0."); + } + } + + /** + * Handles internal events that come to this entity. + */ + public void body() { + super.body(); + + // resets variables to default values + pivotGridlets_.clear(); + } + + /** + * Sets the maximum number of pivot jobs. Similarly to the aggressive + * backfilling in MAUI, the system administrator can specify how many + * pivots can be considered when scheduling a job. That is, a job can + * be used to backfill if it does not delay the first maxPivots jobs + * in the waiting queue. If this parameter is very large, the policy + * will behave like conservative backfilling + * @param maxPivots the maximum number of pivots + * @return <tt>true</tt> if the number of pivots has been set; + * <tt>false</tt> otherwise. + */ + public boolean setMaximumNumberOfPivots(int maxPivots) { + if(maxPivots < 1) + return false; + + maxPivots_ = maxPivots; + return true; + } + + /** + * Schedules/adds to the queue a new <tt>Gridlet</tt> received by the + * <tt>GridResource</tt> entity. + * @param gridlet a Gridlet object to be executed + * @param ack an acknowledgement, i.e. <tt>true</tt> if the + * user wants to know whether this operation is successful + * or not, <tt>false</tt> otherwise. + */ + public void gridletSubmit(Gridlet gridlet, boolean ack) { + int reqPE = gridlet.getNumPE(); + + try { + // reject the Gridlet if it requires more PEs than the resource + // is able to provide + if(reqPE > super.totalPE_){ + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " user requires " + gridlet.getNumPE() + " PEs."); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs."); + gridlet.setGridletStatus(Gridlet.FAILED); + super.sendFinishGridlet(gridlet); + return; + } + } + catch(Exception ex) { + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet"); + } + + // Create a resource Gridlet + SSGridlet sgl = new SSGridlet(gridlet); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sgl); + + //---------------------------------------------------------- + + sgl.setStatus(Gridlet.QUEUED); + queuedGridlets_.add(sgl); + backfillGridlets(GridSim.clock()); + + // sends back an ack if required + if (ack == true) { + super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true, + gridlet.getGridletID(), gridlet.getUserID() + ); + } + } + + /** + * Cancels a Gridlet running or in the waiting queue. + * This method will search the running and waiting queues. + * The User ID is important as many users might have the same + * Gridlet ID in the lists. If a Gridlet is cancelled and the gridlet was + * either running or was a pivot, then the availability profile is updated. + * After that, the backfilling algorithm is called to check which + * gridlets can be started or scheduled. + * <b>NOTE:</b> + * <ul> + * <li> Before cancelling a Gridlet, this method updates when + * the expected completion time of the Gridlet is. If the + * completion time is smaller than the current time, then + * the Gridlet is considered to be <tt>finished</tt>. + * Therefore the Gridlet cannot be cancelled. + * + * <li> Once a Gridlet has been cancelled, it cannot be resumed + * to execute again since this method will pass the Gridlet + * back to sender, i.e. the <tt>userId</tt>. + * + * <li> If a Gridlet cannot be found in either execution and + * waiting lists, then a <tt>null</tt> Gridlet will be send back + * to sender, i.e. the <tt>userId</tt>. + * </ul> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @pre gridletId > 0 + * @pre userId > 0 + */ + public void gridletCancel(int gridletId, int userId) { + double currentTime = GridSim.clock(); + + // stores the gridlet if found + SSGridlet sgl = null; + boolean found = false; + boolean updateProfile = false; + + // Look for the Gridlet in the running queue + sgl = findSSGridlet(runningGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // if the Gridlet's finish time is smaller than the current + // time or the status is FINISHED, it means that the Gridlet + // has finished, but has not been removed from the running + // queue yet. It will probably be done shortly, + // so just send a null to the user. + if(sgl.getStatus() == Gridlet.SUCCESS || + sgl.getActualFinishTime() <= currentTime){ + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; // return as it is impossible to cancel the Gridlet + } + else{ + // remove from the queue before compressing the schedule + runningGridlets_.remove(sgl); + updateProfile = true; + } + } + + if(!found) { + // Look for the gridlet in the waiting queue + sgl = findSSGridlet(queuedGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // Get the Gridlet from the waiting queue and + // remove from the queue before compressing the schedule + queuedGridlets_.remove(sgl); + + // if start time has been set, then it means that gridlet is + // a pivot. So, we need to remove it from the pivot list + if(sgl.getStartTime() > 0) { + pivotGridlets_.remove(sgl); + updateProfile = true; + } + } + } + + // If the Gridlet could not be found in neither queue, then send a null + // Gridlet to the user and return because there is no need to + // compress the schedule + if(!found) { + System.out.println(super.get_name() + ".gridletCancel():" + + " Cannot find Gridlet #" + gridletId + " for User #" + userId); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; + } + + // check whether the Gridlet is running + boolean isRunning = sgl.getStatus() == Gridlet.INEXEC; + sgl.setStatus(Gridlet.CANCELED); + + //----------------- USED FOR DEBUGGING PURPOSES ONLY ------------------- + + // If a gridlet has been cancelled, then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, sgl); + + //---------------------------------------------------------------------- + + // remove/update entries of the gridlet in the profile + if(updateProfile) { + removeGridlet(isRunning, sgl); + backfillGridlets(currentTime); + + //------------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- + + // Inform the listeners about the new schedule + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //---------------------------------------------------------------------- + } + + // sends the Gridlet back to user + sgl.finalizeGridlet(); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + sgl.getGridlet(), gridletId, userId); + } + + /** + * Pauses a <tt>Gridlet</tt> only if it is currently executing. + * <b>NOTE: This operation is not supported. </b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know + * whether this operation is success or not, <tt>false</tt> + * otherwise. + */ + public void gridletPause(int gridletId, int userId, boolean ack){ + System.out.println(super.get_name() + + ".gridletMove(): not supported at the moment."); + } + + /** + * Moves a Gridlet from this GridResource entity to a different one. + * <b>NOTE: This operation is not supported. </b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @param destId a new destination GridResource ID for this Gridlet + * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know + * whether this operation is success or not, <tt>false</tt> + * otherwise + */ + public void gridletMove(int gridletId, int userId, int destId, boolean ack){ + System.out.println(super.get_name() + + ".gridletPause(): not supported at the moment."); + } + + /** + * Resumes a Gridlet only in the paused list. + * <b>NOTE: This operation is not supported. </b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know + * whether this operation is success or not, <tt>false</tt> + * otherwise + */ + public void gridletResume(int gridletId, int userId, boolean ack){ + System.out.println(super.get_name() + + ".gridletResume(): not supported at the moment."); + } + + // -------------------- PROTECTED METHODS ---------------------------- + + /** + * Tries to schedule a gridlet. That is, make the gridlet the pivot, + * or the first gridlet in the queue. If that is not possible, then return + * false. If the gridlet is the first into the queue, then updates the + * pivot, extra nodes and the shadow time. The shadow time will + * be the start time of the gridlet whereas the extra PEs will be the + * PEs left unused when the gridlet starts execution. + * @param sgl the resource gridlet + * @return <tt>true</tt> if scheduled; <tt>false</tt> otherwise. + */ + protected boolean scheduleGridlet(SSGridlet sgl) { + + // if there are enough pivots already, then just return + if(pivotGridlets_.size() >= maxPivots_) + return false; + + super.enqueueGridlet(sgl); + pivotGridlets_.add(sgl); + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + + return true; + } + + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether the first gridlet + * in the waiting queue can be started. If it cannot be started, them + * tries to backfill with jobs waiting in the queue. The method also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + int itemsFinished = 0; + double currentTime = GridSim.clock(); + int itemsStarted = 0; + + itemsFinished = finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + AvailabilityProfileEntry currentStatus = + availProfile_.removePastEntries(currentTime); + if(currentStatus != null) { + resource_.resetFreePERanges(currentStatus.getPERanges()); + } + + itemsStarted = backfillGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0) { + GridSim.notifyListeners(this.get_id(), + AllocationAction.SCHEDULE_CHANGED, true); + } + } + + /** + * This method backfills/starts gridlets that are in the queue + * @param currentTime the current simulation time + * @return the number of gridlets started + */ + protected int backfillGridlets(double currentTime) { + int gridletStarted = 0; + + // checks the pivots first + Iterator<SSGridlet> iter = pivotGridlets_.iterator(); + while(iter.hasNext()) { + SSGridlet pivot = iter.next(); + if(pivot.getStartTime() <= currentTime) { + gridletStarted++; + queuedGridlets_.remove(pivot); // pivots should be at the beginning + runningGridlets_.add(pivot); + // change Gridlet status + pivot.setStatus(Gridlet.INEXEC); + super.sendInternalEvent(pivot.getActualFinishTime()-currentTime, + UPDATE_SCHEDULE_TAG); + iter.remove(); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //---------------------------------------------------------- + } + } + + // order jobs according to the ordering heuristic provided. + // That is, if one was provided by the user. + if(super.jobOrderHeuristic_ != null) + Collections.sort(queuedGridlets_, super.jobOrderHeuristic_); + + // Start the execution of Gridlets that are queued + iter = queuedGridlets_.iterator(); + while (iter.hasNext()) { + SSGridlet gridlet = iter.next(); + if(gridlet.getStartTime() > 0) + continue; + + boolean success = startGridlet(gridlet); + + // if the job could not be scheduled immediately, then enqueue it + if(success) { + iter.remove(); + gridletStarted++; + } + else { + success = scheduleGridlet(gridlet); + } + + // Inform visualiser that the gridlet was either started or scheduled + if(success) { + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_SCHEDULED, true, gridlet); + + //---------------------------------------------------------- + } + } + + return gridletStarted; + } + + /** + * Allocates a Gridlet into free PEs, sets the Gridlet status to INEXEC, + * updates the availability profile and the ranges currently available + * @param sgl a SSGridlet object + * @return <tt>true</tt> if there is are free PE to process this Gridlet, + * <tt>false</tt> otherwise + * @pre sgl != null + * @post $none + */ + protected boolean startGridlet(SSGridlet sgl) { + int reqPE = sgl.getNumPE(); + // Just to make the easy backfilling faster and avoid checking the + // availability profile unnecessarily + if(resource_.getNumFreePE() < reqPE) + return false; + + return super.startGridlet(sgl); + } + + // ------------------------- PRIVATE METHODS ---------------------------- + + /** + * This method removes/updates all the entries of a gridlet from the profile + * and updates the ranges of current free PEs if the gridlet was in execution. + * @param wasRunning <tt>true</tt> if the gridlet was running; + * <tt>false</tt> otherwise. + * @param gridlet the Gridlet to be removed + */ + private void removeGridlet(boolean wasRunning, SSGridlet gridlet) { + if(!gridlet.hasReserved()) { + + // removes the gridlet from the profile + updateEntriesAtProfile(wasRunning, gridlet); + } + } +} Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java 2008-04-09 01:48:26 UTC (rev 168) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java 2008-04-11 00:58:22 UTC (rev 169) @@ -67,14 +67,6 @@ } /** - * Increases the end of the range - * @return returns the new value of the range - */ - public int increaseEnd(){ - return ++end_; - } - - /** * Returns the number of PEs in this range * @return the number of PEs */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-04-09 01:48:26 UTC (rev 168) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-04-11 00:58:22 UTC (rev 169) @@ -46,7 +46,7 @@ // the finish time of the Gridlet private double actualFinishTime_; - // estimation of Gridlet finished time + // estimation of Gridlet finished time private double expectedFinishTime_; // num PE needed to execute this Gridlet @@ -448,7 +448,7 @@ expectedFinishTime_ = time; } - /** + /** * Gets the Gridlet's finish time * @return finish time of a gridlet or <tt>-1.0</tt> if * it cannot finish in this hourly slot Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java 2008-04-09 01:48:26 UTC (rev 168) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java 2008-04-11 00:58:22 UTC (rev 169) @@ -47,24 +47,29 @@ public static final int EB_PARALLEL_SPACE_SHARED = 11; /** Parallel spaced-shared system using First Come First Serve (FCFS) + * algorithm and aggressive backfilling (EASY) with configurable number of + * pivots */ + public static final int MAUI_EB_PARALLEL_SPACE_SHARED = 12; + + /** Parallel spaced-shared system using First Come First Serve (FCFS) * algorithm, conservative backfilling and supporting advance reservations */ - public static final int AR_PARALLEL_SPACE_SHARED = 12; + public static final int AR_PARALLEL_SPACE_SHARED = 13; /** Parallel spaced-shared system using multiple * partitions and aggressive (EASY) backfilling */ - public static final int EB_MULTI_PARTITIONS = 13; + public static final int EB_MULTI_PARTITIONS = 14; /** Parallel spaced-shared system using multiple * partitions and conservative backfilling */ - public static final int CB_MULTI_PARTITIONS = 14; + public static final int CB_MULTI_PARTITIONS = 15; /** Parallel spaced-shared system using multiple * partitions, conservative backfilling and advance reservations */ - public static final int ARCB_MULTI_PARTITIONS = 15; + public static final int ARCB_MULTI_PARTITIONS = 16; /** Parallel spaced-shared system using multiple * partitions, aggressive (EASY) backfilling and advance reservations */ - public static final int AREB_MULTI_PARTITIONS = 16; + public static final int AREB_MULTI_PARTITIONS = 17; /** * Allocates a new {@link TResourceCharacteristics} object. @@ -171,6 +176,7 @@ // Assuming all PEs in all Machine have same rating. case TResourceCharacteristics.CB_PARALLEL_SPACE_SHARED: case TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED: + case TResourceCharacteristics.MAUI_EB_PARALLEL_SPACE_SHARED: case TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED: case TResourceCharacteristics.EB_MULTI_PARTITIONS: case TResourceCharacteristics.CB_MULTI_PARTITIONS: @@ -290,6 +296,10 @@ policyName = "EB_PARALLEL_SPACE_SHARED"; break; + case TResourceCharacteristics.MAUI_EB_PARALLEL_SPACE_SHARED: + policyName = "MAUI_EB_PARALLEL_SPACE_SHARED"; + break; + case TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED: policyName = "AR_PARALLEL_SPACE_SHARED"; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-09 01:48:20
|
Revision: 168 http://gridsim.svn.sourceforge.net/gridsim/?rev=168&view=rev Author: marcos_dias Date: 2008-04-08 18:48:26 -0700 (Tue, 08 Apr 2008) Log Message: ----------- This update includes the implementation of gridlet cancellation in the multiple partition easy backfilling resource allocation policy. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java 2008-04-09 01:48:26 UTC (rev 168) @@ -0,0 +1,215 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource using an aggressive + * backfilling policy without advance reservation features but with multiple + * partitions. The jobs are read from a trace file. Additionally, this example + * cancels some gridlets submitted. This example has been implemented in order + * to test the job cancellation features. To test this example, you can use + * one of the traces included in the workloads directory. + */ + +package examples.workload.parallel; + +import examples.QueuePredicateExample; +import examples.WorkloadWithCancellation; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.EBMultiplePartitions; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + +/** + * Test Driver class for this example + */ +public class TurboExampleEBMultiQueuesCancellation +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + WorkloadWithCancellation workload = + new WorkloadWithCancellation("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy with + // multiple partitions and without advance reservation features + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, + time_zone, cost); + + EBMultiplePartitions policy = null; + try { + policy = new EBMultiplePartitions(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for short jobs, one for medium length jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + // divide the resources equally amongst the partitions + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-04-07 23:06:47 UTC (rev 167) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-04-09 01:48:26 UTC (rev 168) @@ -444,17 +444,125 @@ return -1; } - /** - * Cancels a Gridlet running or in the waiting queue.<br> - * <b>NOTE: Not implemented YET.</b> + /** + * Cancels a Gridlet running or in the waiting queue. + * This method will search the running and waiting queues. + * The User ID is important as many users might have the same + * Gridlet ID in the lists. If a Gridlet is cancelled and the gridlet was + * either running or was a pivot, then the availability profile is updated. + * After that, the backfilling algorithm is called to check which + * gridlets can be started or scheduled. + * <b>NOTE:</b> + * <ul> + * <li> Before cancelling a Gridlet, this method updates when + * the expected completion time of the Gridlet is. If the + * completion time is smaller than the current time, then + * the Gridlet is considered to be <tt>finished</tt>. + * Therefore the Gridlet cannot be cancelled. + * + * <li> Once a Gridlet has been cancelled, it cannot be resumed + * to execute again since this method will pass the Gridlet + * back to sender, i.e. the <tt>userId</tt>. + * + * <li> If a Gridlet cannot be found in either execution and + * waiting lists, then a <tt>null</tt> Gridlet will be send back + * to sender, i.e. the <tt>userId</tt>. + * </ul> * @param gridletId a Gridlet ID * @param userId the user or owner's ID of this Gridlet * @pre gridletId > 0 * @pre userId > 0 */ public void gridletCancel(int gridletId, int userId) { - System.out.println(super.get_name() + - ".gridletCancel(): not supported at the moment."); + double currentTime = GridSim.clock(); + + // stores the gridlet if found + SSGridlet sgl = null; + boolean found = false; + boolean updateProfile = false; + + // Look for the Gridlet in the running queue + sgl = findSSGridlet(runningGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // if the Gridlet's finish time is smaller than the current + // time or the status is FINISHED, it means that the Gridlet + // has finished, but has not been removed from the running + // queue yet. It will probably be done shortly, + // so just send a null to the user. + if(sgl.getStatus() == Gridlet.SUCCESS || + sgl.getActualFinishTime() <= currentTime){ + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; // return as it is impossible to cancel the Gridlet + } + else{ + // remove from the queue before compressing the schedule + runningGridlets_.remove(sgl); + updateProfile = true; + } + } + + if(!found) { + // Look for the gridlet in the waiting queue + sgl = findSSGridlet(queuedGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // Get the Gridlet from the waiting queue and + // remove from the queue before compressing the schedule + queuedGridlets_.remove(sgl); + + // if start time has been set, then it means that gridlet is + // a pivot. So, we need to set the pivot of the corresponding + // queue partition to null + if(sgl.getStartTime() > 0) { + EasyBackFillingPartition pt = getPartition(sgl.getPartitionID()); + pt.pivot_ = null; + updateProfile = true; + } + } + } + + // If the Gridlet could not be found in neither queue, then send a null + // Gridlet to the user and return because there is no need to + // compress the schedule + if(!found) { + System.out.println(super.get_name() + ".gridletCancel():" + + " Cannot find Gridlet #" + gridletId + " for User #" + userId); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; + } + + // check whether the Gridlet is running + sgl.setStatus(Gridlet.CANCELED); + + //----------------- USED FOR DEBUGGING PURPOSES ONLY ------------------- + + // If a gridlet has been cancelled, then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, sgl); + + //---------------------------------------------------------------------- + + // remove/update entries of the gridlet in the profile + if(updateProfile) { + removeGridlet(sgl); + backfillGridlets(currentTime); + + //------------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- + + // Inform the listeners about the new schedule + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //---------------------------------------------------------------------- + } + + // sends the Gridlet back to user + sgl.finalizeGridlet(); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + sgl.getGridlet(), gridletId, userId); } /** @@ -906,6 +1014,20 @@ return gridletStarted; } + // ------------------------- PRIVATE METHODS ---------------------------- + + /** + * This method removes/updates all the entries of a gridlet from the profile. + * @param gridlet the Gridlet to be removed + */ + private void removeGridlet(SSGridlet gridlet) { + if(!gridlet.hasReserved()) { + + // removes the gridlet from the profile + profile_.updateEntriesAtProfile(gridlet); + } + } + /* * This method obtains the queue from the profile and does a casting */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-04-07 23:06:47 UTC (rev 167) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-04-09 01:48:26 UTC (rev 168) @@ -949,14 +949,14 @@ transferPEs(partitionId, allocatedRanges, startTime, finishTime); MPProfileEntry entry = getPrecedingEntry(startTime); - if(entry.getTime() == startTime) { + if(entry != null && entry.getTime() == startTime) { entry.decreaseGridlet(); if(entry.getNumGridlets() == 0) super.remove(entry); } entry = getPrecedingEntry(finishTime); - if(entry.getTime() == startTime) { + if(entry != null && entry.getTime() == finishTime) { entry.decreaseGridlet(); if(entry.getNumGridlets() == 0) super.remove(entry); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-07 23:06:43
|
Revision: 167 http://gridsim.svn.sourceforge.net/gridsim/?rev=167&view=rev Author: marcos_dias Date: 2008-04-07 16:06:47 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Small improvements in the java comments and some updates in getting free time slots from availability info objects. Modified Paths: -------------- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java branches/gridsim4.0-branch3/source/gridsim/Accumulator.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/Machine.java branches/gridsim4.0-branch3/source/gridsim/MachineList.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlot.java Modified: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2008-04-07 23:06:47 UTC (rev 167) @@ -88,6 +88,7 @@ generators = new ArrayList(); // Add this to Sim_system automatically Sim_system.add(this); + super.setName(name); // sets the thread name to ease debugging } /** @@ -111,6 +112,7 @@ generators = new ArrayList(); // Add this to Sim_system automatically Sim_system.add(this); + super.setName(name); // sets the thread name to ease debugging } /** Modified: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java 2008-04-07 23:06:47 UTC (rev 167) @@ -2,7 +2,6 @@ package eduni.simjava; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; Modified: branches/gridsim4.0-branch3/source/gridsim/Accumulator.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/Accumulator.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/Accumulator.java 2008-04-07 23:06:47 UTC (rev 167) @@ -93,43 +93,20 @@ /** * Calculates the mean of accumulated items - * @deprecated As of GridSim 2.1, replaced by {@link #getMean()} * @return the mean of accumalated items * @pre $none * @post $none */ - public double mean() { - return this.getMean(); - } - - /** - * Calculates the mean of accumulated items - * @return the mean of accumalated items - * @pre $none - * @post $none - */ public double getMean() { return mean_; } /** * Calculates the standard deviation of accumulated items - * @deprecated As of GridSim 2.1, replaced by - * {@link #getStandardDeviation()} * @return the Standard Deviation of accumulated items * @pre $none * @post $none */ - public double sd() { - return this.getStandardDeviation(); - } - - /** - * Calculates the standard deviation of accumulated items - * @return the Standard Deviation of accumulated items - * @pre $none - * @post $none - */ public double getStandardDeviation() { return Math.sqrt( this.getVariance() ); } @@ -146,105 +123,52 @@ /** * Finds the smallest number of accumulated items - * @deprecated As of GridSim 2.1, replaced by {@link #getMin()} * @return the smallest of accumulated items * @pre $none * @post $none */ - public double min() { - return this.getMin(); - } - - /** - * Finds the smallest number of accumulated items - * @return the smallest of accumulated items - * @pre $none - * @post $none - */ public double getMin() { return min_; } /** * Finds the largest number of accumulated items - * @deprecated As of GridSim 2.1, replaced by {@link #getMax()} * @return the largest of accumulated items * @pre $none * @post $none */ - public double max() { - return this.getMax(); - } - - /** - * Finds the largest number of accumulated items - * @return the largest of accumulated items - * @pre $none - * @post $none - */ public double getMax() { return max_; } /** * Finds the last accumulated item - * @deprecated As of GridSim 2.1, replaced by {@link #getLast()} * @return the last accumulated item * @pre $none * @post $none */ - public double last() { - return this.getLast(); - } - - /** - * Finds the last accumulated item - * @return the last accumulated item - * @pre $none - * @post $none - */ public double getLast() { return last_; } /** * Counts the number of items accumulated so far - * @deprecated As of GridSim 2.1, replaced by {@link #getCount()} * @return the number of items accumulated so far * @pre $none * @post $result >= 0 */ - public int count() { - return this.getCount(); - } - - /** - * Counts the number of items accumulated so far - * @return the number of items accumulated so far - * @pre $none - * @post $result >= 0 - */ public int getCount() { return n_; } /** * Calculates the sum of accumulated items - * @deprecated As of GridSim 2.1, replaced by {@link #getSum()} + * <b>NOTE:</b> The sum returned by this method is + * (number of items * mean of the accumulated items) * @return the sum of accumulated items * @pre $none * @post $none */ - public double sum() { - return this.getSum(); - } - - /** - * Calculates the sum of accumulated items - * @return the sum of accumulated items - * @pre $none - * @post $none - */ public double getSum() { return n_ * mean_; } @@ -252,20 +176,9 @@ /** * Determines the size of Accumulator object * @return the size of this object - * @deprecated As of GridSim 2.1, replaced by {@link #getByteSize()} * @pre $none * @post $result > 0 */ - public static int ByteSize() { - return getByteSize(); - } - - /** - * Determines the size of Accumulator object - * @return the size of this object - * @pre $none - * @post $result > 0 - */ public static int getByteSize() { int totalInt = 4; // contains only 1 int Modified: branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java 2008-04-07 23:06:47 UTC (rev 167) @@ -10,14 +10,10 @@ package gridsim; import java.util.Calendar; -import java.util.LinkedList; import eduni.simjava.Sim_entity; import eduni.simjava.Sim_event; import eduni.simjava.Sim_port; -import gridsim.gui.AllocationAction; -import gridsim.gui.DefaultGridSimVisualizer; -import gridsim.turbo.ScheduleItem; /** * AllocPolicy is an abstract class that handles the internal Modified: branches/gridsim4.0-branch3/source/gridsim/Machine.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/Machine.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/Machine.java 2008-04-07 23:06:47 UTC (rev 167) @@ -86,7 +86,7 @@ * @pre id >= 0 * @post $none */ - public int getMIPSRating(int peID){ + public int getMIPSRating(int peID) { return MIPSRatingPE_; } @@ -98,7 +98,7 @@ * @pre $none * @post $result >= 0 */ - public int getMIPSRating(){ + public int getMIPSRating() { return numPE_ * MIPSRatingPE_; } @@ -118,7 +118,7 @@ if (PEStatuses_[peID] == status) return false; - if(status){ + if(status) { busyPE_++; } else{ @@ -183,7 +183,7 @@ * Returns a list of free PEs * @return the list of free PEs */ - public LinkedList<Integer> getListFreePE(){ + public LinkedList<Integer> getListFreePE() { LinkedList<Integer> result = new LinkedList<Integer>(); for(int index=0; index<numPE_; index++){ if(!PEStatuses_[index]){ Modified: branches/gridsim4.0-branch3/source/gridsim/MachineList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/MachineList.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/MachineList.java 2008-04-07 23:06:47 UTC (rev 167) @@ -74,7 +74,7 @@ * Returns the size of this list of machines * @return the size of the list */ - public int size(){ + public int size() { return map_.size(); } @@ -82,7 +82,7 @@ * Returns an iterator over the values in this list. * @return an iterator over the elements in this list. */ - public Iterator iterator(){ + public Iterator<Machine> iterator() { return map_.values().iterator(); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-04-07 23:06:47 UTC (rev 167) @@ -26,7 +26,8 @@ * directed to these partitions using a partition predicate * ({@link QueuePartitionPredicate}. A partition can borrow resources from * another when it requires and the resources are not being used by the - * other partition. + * other partition. However, you can change this behaviour + * by calling {@link #setAllowBorrowing(boolean)}. * * We use an availability profile to store the availability of processing * elements. @@ -41,6 +42,9 @@ * <li> Gridlets cannot be paused nor migrated. * </ul> * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * * @see gridsim.GridSim * @see gridsim.ResourceCharacteristics * @see gridsim.turbo.TAllocPolicy Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-04-07 23:06:47 UTC (rev 167) @@ -25,8 +25,13 @@ * This policy can use multiple partitions or queues and the jobs can be * directed to these partitions using a partition predicate * ({@link QueuePartitionPredicate}. A partition can borrow resources from - * another when it requires and the resources are not being used by the - * other partition. + * another when it requires and the resources are not being used by the other + * partition. However, you can change this behaviour + * by calling {@link #setAllowBorrowing(boolean)}. Additionally, this policy + * supports priorities. Jobs are ordered according to their priorities; + * a high priority job can take the place of a pivot with lower priority. + * To change the way that the scheduler assigns priorities to the jobs, please + * see {@link PrioritySelector}. * * We use an availability profile to store the availability of processing * elements. In order to represent the pivots (i.e. the first jobs in the @@ -45,6 +50,9 @@ * <li> Gridlets cannot be paused nor migrated. * </ul> * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * * @see gridsim.GridSim * @see gridsim.ResourceCharacteristics * @see gridsim.turbo.TAllocPolicy Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2008-04-07 23:06:47 UTC (rev 167) @@ -14,7 +14,6 @@ * and a resource providers to negotiate an advance reservation. * * @author Marcos Dias de Assuncao - * * @since GridSim Turbo Alpha 0.1 * * @see Reservation Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2008-04-07 23:06:47 UTC (rev 167) @@ -24,9 +24,10 @@ * {@link TResourceCharacteristics#AR_PARALLEL_SPACE_SHARED}. In addition, * a resource's scheduler should be extended from * {@link ARTPolicy} class. - * - * @author Marcos Dias de Assuncao - + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * * @see gridsim.GridResource * @see gridsim.GridSim * @see gridsim.ResourceCharacteristics Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-04-07 23:06:47 UTC (rev 167) @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; +import java.util.LinkedList; /** * The {@link AvailabilityInfo} class represents a list of entries @@ -24,7 +25,7 @@ * @see PERange * @see PERangeList * @see ARParallelSpaceShared - * @see ARParallelSpaceShared#handleQueryAvailability(ARMessage) + * @see ARTPolicy#handleQueryAvailability(ARMessage) */ public class AvailabilityInfo extends ArrayList<AvailabilityInfoEntry> { @@ -384,11 +385,143 @@ } /** + * Returns the time slots contained in this availability information object + * within a specified period of time. <br> + * <b>NOTE:</b> The time slots returned by this method do not overlap. + * That is, they are not the scheduling options of a given job. + * @param startTime the start time of the period. + * @param finishTime the finish time of the period. + * @return a linked list with the time slots contained in this availability + * information object within a specified period of time. + */ + public LinkedList<TimeSlot> getTimeSlots(double startTime, double finishTime) { + LinkedList<TimeSlot> slots = new LinkedList<TimeSlot>(); + + // gets the part of the profile relevant to create the slots + AvailabilityInfo subProfile = getSubAvailabilityInfo(startTime, finishTime); + + if(subProfile == null || subProfile.size() == 0) + return slots; + + double slotStart = 0; + double slotFinish = 0; + int startIdx = 0; + int endIdx = 0; + AvailabilityInfoEntry entry = null; + AvailabilityInfoEntry nextEntry = null; + PERangeList rangesSlot = null; + PERangeList intersect = null; + + for(int i=0; i<subProfile.size(); i++) { + entry = subProfile.get(i); + slotStart = entry.getTime(); + startIdx = i; + endIdx = i; + + if(entry.getNumPE() == 0) + continue; + + // check all time slots starting at slotStart + do { + intersect = entry.getAvailRanges().clone(); + rangesSlot = intersect.clone(); + for(int j=i+1; j<subProfile.size(); j++) { + nextEntry = subProfile.get(j); + intersect = PERangeList.intersection(intersect, + nextEntry.getAvailRanges()); + + if(intersect != null && intersect.getNumPE() > 0) { + rangesSlot = intersect.clone(); + endIdx = j; + continue; + } + else + break; + } + + if(intersect != null && intersect.getNumPE() > 0) { + slotFinish = finishTime; + } + else { + slotFinish = nextEntry.getTime(); + } + + TimeSlot slot = new TimeSlot(slotStart, slotFinish, rangesSlot); + slots.add(slot); + + for(int j=startIdx; j<=endIdx; j++) { + nextEntry = subProfile.get(j); + PERangeList difference = + PERangeList.difference(nextEntry.getAvailRanges(), rangesSlot); + nextEntry.setAvailRanges(difference); + } + } while(entry.getNumPE() > 0); + } + + return slots; + } + + /** + * Returns part of the availability information.<br> + * <b>NOTE:</b> The entries of the sub-info are clones of the original + * info object's. + * @param startTime the start time of the resulting part + * @param finishTime the finish time of the resulting part + * @return part of the availability information. + */ + protected AvailabilityInfo getSubAvailabilityInfo(double startTime, double finishTime) { + AvailabilityInfo info = new AvailabilityInfo(); + + // start time cannot be smaller than the start time of the info obj + if(startTime < startTime_) + startTime = startTime_; + + // start time cannot be larger than the finish time of the info obj + if(startTime > finishTime_) { + return null; + } + + int length = super.size(); + AvailabilityInfoEntry entry = null; + AvailabilityInfoEntry firstEntry = null; + entry = getPrecedingEntry(startTime); + int index = super.indexOf(entry); + + firstEntry = entry.clone(startTime); + info.setStartTime(startTime); + info.add(firstEntry); + AvailabilityInfoEntry previousEntry = firstEntry; + + for(int i=index+1; i<length; i++) { + entry = super.get(i); + if(entry.getTime() <= startTime) + continue; + if(entry.getTime() > finishTime) { + break; + } + else { + PERangeList peList = entry.getAvailRanges(); + peList = (peList != null) ? peList.clone() : new PERangeList(); + + if( !previousEntry.getAvailRanges().equals(peList)) { + AvailabilityInfoEntry newEntry = entry.clone(entry.getTime()); + info.add(newEntry); + previousEntry = newEntry; + } + } + } + + info.setFinishTime(finishTime); + return info; + } + + /** * Creates a string representation of the list * @return a string representation */ public String toString() { - String result = "Availability={\n"; + String result = "Availability={startTime=" + startTime_ + + ", finishTime=" + finishTime_ + "\n"; for(AvailabilityInfoEntry entry : this){ result += entry + "\n"; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java 2008-04-07 23:06:47 UTC (rev 167) @@ -107,6 +107,15 @@ } /** + * Returns the number of Gridlets that rely on this entry to mark + * their expected completion time or their anchor point + * @return the number of Gridlets that use this entry + */ + public int getNumGridlets() { + return numGridlets_; + } + + /** * Adds the ranges provided to the list of ranges available * @param list the list to be added * @return <tt>true</tt> if the ranges changed as result of this call Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-04-07 23:06:47 UTC (rev 167) @@ -106,6 +106,39 @@ } /** + * Returns part of the availability profile.<br> + * <b>NOTE:</b> The entries of the sub-profile are clones of the original + * profile object's. + * @param startTime the start time of the resulting part + * @param finishTime the finish time of the resulting part + * @return part of the availability profile. + */ + protected AvailabilityProfile getSubProfile(double startTime, double finishTime) { + AvailabilityProfile subProfile = new AvailabilityProfile(); + AvailabilityProfileEntry previousEntry = null; + + for(AvailabilityProfileEntry entry : this) { + if(entry.getTime() < startTime) + continue; + if(entry.getTime() > finishTime) { + break; + } + else { + PERangeList peList = entry.getPERanges(); + peList = (peList != null) ? peList.clone() : new PERangeList(); + + if(previousEntry == null || !previousEntry.getPERanges().equals(peList)) { + AvailabilityProfileEntry newEntry = entry.clone(entry.getTime()); + subProfile.add(newEntry); + previousEntry = newEntry; + } + } + } + + return subProfile; + } + + /** * Creates an string representation of the profile * @return an string representation */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2008-04-07 23:06:47 UTC (rev 167) @@ -128,6 +128,19 @@ } /** + * Returns a clone of this entry. The ranges are cloned, but the time + * and the number of gridlets relying on this entry are not. + * @param time the time for the new entry + * @return the new entry with the number of gridlets set to default. + */ + public AvailabilityProfileEntry clone(double time) { + PERangeList ranges = ranges_ == null ? null : ranges_.clone(); + AvailabilityProfileEntry entry = + new AvailabilityProfileEntry(time, ranges); + return entry; + } + + /** * Creates a string representation of this entry */ public String toString() { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-04-07 23:06:47 UTC (rev 167) @@ -22,7 +22,8 @@ * multiple partitions or queues and the jobs can be directed to these partitions * using a partition predicate ({@link QueuePartitionPredicate}. A partition * can borrow resources from another when it requires and the resources are - * not being used by the other partition. + * not being used by the other partition. However, you can change this behaviour + * by calling {@link #setAllowBorrowing(boolean)}. * * We use an availability profile to store the availability of processing * elements. In order to represent the pivots (i.e. the first jobs in the @@ -42,6 +43,9 @@ * <li> This policy does not support advance reservations. * </ul> * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * * @see gridsim.GridSim * @see gridsim.ResourceCharacteristics * @see gridsim.turbo.TAllocPolicy Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-04-07 23:06:47 UTC (rev 167) @@ -28,8 +28,13 @@ * multiple partitions or queues and the jobs can be directed to these partitions * using a partition predicate ({@link QueuePartitionPredicate}. A partition * can borrow resources from another when it requires and the resources are - * not being used by the other partition. The implementation of this policy is - * based on the following paper: + * not being used by the other partition. However, you can change this behaviour + * by calling {@link #setAllowBorrowing(boolean)}. Additionally, this policy + * supports priorities. Jobs are ordered according to their priorities; + * a high priority job can take the place of a pivot with lower priority. + * To change the way that the scheduler assigns priorities to the jobs, please + * see {@link PrioritySelector}. The implementation of this policy is based + * on the following paper: * <p> * <ul> * <li> Barry G. Lawson and Evgenia Smirni, Multiple-Queue Backfilling Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java 2008-04-07 23:06:47 UTC (rev 167) @@ -13,8 +13,9 @@ /** * Class used to order the gridlets according to their * potential start times - * @author Marcos Dias de Assuncao - * + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 */ public class OrderGridletByStartTime implements Comparator<SSGridlet> { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java 2008-04-07 23:06:47 UTC (rev 167) @@ -14,9 +14,10 @@ * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 + * * @see PERangeList - * @see CBParallelSpaceShared - * @see EBParallelSpaceShared + * @see AvailabilityProfileEntry + * @see AvailabilityProfile */ public class PERange implements Cloneable, Comparable<PERange> { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java 2008-04-07 23:06:47 UTC (rev 167) @@ -3,6 +3,7 @@ /** * This class represents a partition in this scheduler. It only * stores a few variables used to control the partition. + * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java 2008-04-07 23:06:47 UTC (rev 167) @@ -16,8 +16,8 @@ * and its properties. * * @author Marcos Dias de Assuncao - * * @since GridSim Turbo Alpha 0.1 + * * @invariant $none */ public class Reservation implements Cloneable, Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2008-04-07 23:06:47 UTC (rev 167) @@ -22,7 +22,6 @@ * and query. * * @author Marcos Dias de Assuncao - * * @since GridSim Turbo Alpha 0.1 */ public class ReservationRequester extends GridSim { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java 2008-03-31 00:27:24 UTC (rev 166) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java 2008-04-07 23:06:47 UTC (rev 167) @@ -241,7 +241,7 @@ * @param ranges the list of ranges available */ public void resetFreePERanges(PERangeList ranges) { - freePERanges_ = ranges == null ? null : ranges.clone(); // clones the list to avoid conflict + freePERanges_ = (ranges == null) ? null : ranges.clone(); // clones the list to avoid conflict } /** Added: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlot.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlot.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlot.java 2008-04-07 23:06:47 UTC (rev 167) @@ -0,0 +1,120 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +/** + * This class defines a time slot. A time slot can be used to represent a + * free fragment in the scheduling queue. This may be useful for users who + * want to implement policies that perform best-fit, next-fit or worst-fit + * time slot selection. For a description on how time slots can be utilised, + * please read the following paper on the MAUI scheduler: + * <ul> + * <li> David B. Jackson, Quinn Snell and Mark J. Clement. Core Algorithms + * of the Maui Scheduler, Revised Papers from the 7th International + * Workshop on Job Scheduling Strategies for Parallel Processing + * (JSSPP '01), Lecture Notes in Computer Science, pp. 87-102, London, UK. + * </ul> + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see gridsim.turbo.PERange + * @see gridsim.turbo.PERangeList + */ +public class TimeSlot { + + private double startTime_; + private double finishTime_; + private PERangeList ranges_; + + /** + * Default constructor sets + * @param startTime the start time of the time slot + * @param finishTime the finish time of the time slot + * @param ranges the list of PE ranges available at the slot + */ + public TimeSlot(double startTime, double finishTime, PERangeList ranges) { + startTime_ = startTime; + finishTime_ = finishTime; + ranges_ = ranges; + } + + /** + * Sets the start time of the time slot + * @param startTime the start time + * @return <tt>true</tt> if set successfully; <tt>false</tt> otherwise. + * @pre startTime >= 0 + */ + public boolean setStartTime(double startTime) { + if(startTime <0) + return false; + + startTime_ = startTime; + return true; + } + + /** + * Sets the finish time of the time slot + * @param finishTime the finish time + * @return <tt>true</tt> if set successfully; <tt>false</tt> otherwise. + * @pre finishTime >= 0 + */ + public boolean setFinishTime(double finishTime) { + if(finishTime <0) + return false; + + finishTime_ = finishTime; + return true; + } + + /** + * Sets the ranges of the time slot + * @param ranges the ranges of this time slot + * @return <tt>true</tt> if set successfully; <tt>false</tt> otherwise. + * @pre ranges != <tt>null</tt> + */ + public boolean setPERanges(PERangeList ranges) { + if(ranges == null) + return false; + + ranges_ = ranges; + return true; + } + + /** + * Returns the start time of this time slot + * @return the start time of this time slot + */ + public double getStartTime() { + return startTime_; + } + + /** + * Returns the finish time of this time slot + * @return the finish time of this time slot + */ + public double getFinishTime() { + return finishTime_; + } + + /** + * Returns the PE ranges available at the time slot + * @return the PE ranges available at the time slot + */ + public PERangeList getPERanges() { + return ranges_; + } + + /** + * Returns the number of PEs available at the time slot + * @return the number of PEs available at the time slot + */ + public int getNumPE() { + return ranges_ == null ? 0 : ranges_.getNumPE(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-31 00:27:18
|
Revision: 166 http://gridsim.svn.sourceforge.net/gridsim/?rev=166&view=rev Author: marcos_dias Date: 2008-03-30 17:27:24 -0700 (Sun, 30 Mar 2008) Log Message: ----------- This update contains small updates in the policies such as improvement in the descriptions. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2008-03-31 00:27:24 UTC (rev 166) @@ -1,9 +1,10 @@ /* * Author Marcos Dias de Assuncao * Date: September 2007 + * * Description: A simple program to demonstrate of how to use basic - * advanced reservation functionalities, such as create, commit - * and status. + * advanced reservation functionalities, such as create, commit, + * get status of advance reservations and submit gridlets. */ package examples.ar; Modified: branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -1,9 +1,10 @@ /* * Author: Marcos Dias de Assuncao * Date: September 2007 + * * Description: A simple program to demonstrate of how to use basic - * advanced reservation functionalities, such as create, commit - * and status. + * advanced reservation functionalities, such as create, commit, + * get status of advance reservations and submit gridlets. */ package examples.ar; Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: February 2008 * - * Description: This example shows how to create a resource with a conservative + * Description: This example shows how to create a resource using a conservative * backfilling policy with advance reservation features and with multiple * partitions. The jobs are read from a trace file. To test this example, * you can use one of the traces included in the workloads directory. Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource using an aggressive + * backfilling policy with advance reservation features and with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.ar; Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,12 +2,12 @@ * Author Marcos Dias de Assuncao * Date: September 2007 * - * Description: This example shows how to create a resource with a + * Description: This example shows how to create a resource using a * conservative backfilling policy with advance reservation features. The jobs are * read from a trace file. To test this example, you can use one of the traces * included in the workloads directory. The jobs generated by this class are not * advance reservations, however. This example has been created for debugging - * purposes. + * purposes in order to test the normal job scheduling by the policy. */ package examples.workload.ar; Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: September 2007 * - * Description: This example shows how to create a resource with a + * Description: This example shows how to create a resource using a * conservative backfilling policy with advance reservation features. The jobs are * read from a trace file. To test this example, you can use one of the traces * included in the workloads directory. Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-03-31 00:27:24 UTC (rev 166) @@ -5,8 +5,8 @@ * Description: This example creates three resources and three workload * objects. The workloads make advance reservations and submit gridlets * to the resources. The policy used by the resources is conservative - * backfilling with advance reservation. To test this example, you can use - * one of the traces included in the workloads directory. + * backfilling with advance reservation features. To test this example, + * you can use one of the traces included in the workloads directory. */ package examples.workload.ar; Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: September 2007 * - * Description: This example shows how to create a resource with a + * Description: This example shows how to create a resource using a * conservative backfilling policy with advance reservation features. The jobs are * read from a trace file. The workload object cancels some of the gridlets * submitted to the resource. This example has been implemented to test Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,8 +2,8 @@ * Author Marcos Dias de Assuncao * Date: September 2007 * - * Description: This example shows how to create a resource with a - * conservative backfilling policy without advance reservation features. The jobs are + * Description: This example shows how to create a resource using a conservative + * backfilling policy without advance reservation features. The jobs are * read from a trace file. To test this example, you can use one of the traces * included in the workloads directory. */ Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: February 2008 * - * Description: This example shows how to create a resource with a conservative + * Description: This example shows how to create a resource using a conservative * backfilling policy without advance reservation features but with multiple * partitions. The jobs are read from a trace file. To test this example, * you can use one of the traces included in the workloads directory. Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: February 2008 * - * Description: This example shows how to create a resource with an aggressive + * Description: This example shows how to create a resource using an aggressive * backfilling policy without advance reservation features but with multiple * partitions. This example creates the policy with only one partition, however. * This has been done for debugging purposes. The policy should behave like a Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: February 2008 * - * Description: This example shows how to create a resource with an aggressive + * Description: This example shows how to create a resource using an aggressive * backfilling policy without advance reservation features but with multiple * partitions. The jobs are read from a trace file. To test this example, * you can use one of the traces included in the workloads directory. Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: February 2008 * - * Description: This example shows how to create a resource with an aggressive + * Description: This example shows how to create a resource using an aggressive * backfilling policy without advance reservation features. The jobs are * read from a trace file. To test this example, you can use one of the traces * included in the workloads directory. Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-03-31 00:27:24 UTC (rev 166) @@ -2,7 +2,7 @@ * Author Marcos Dias de Assuncao * Date: September 2007 * - * Description: This example shows how to create a resource with a + * Description: This example shows how to create a resource using a * conservative backfilling policy without advance reservation features. * This example has beenn implemented to test the job cancellation. The workload * object created in this example cancels some of the gridlets submitted. The Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-31 00:27:24 UTC (rev 166) @@ -19,7 +19,8 @@ * @since GridSim Turbo Alpha 0.1 */ -public class AvailabilityProfile extends ArrayList<AvailabilityProfileEntry> { +public class AvailabilityProfile extends ArrayList<AvailabilityProfileEntry> + implements Cloneable { private static final long serialVersionUID = -1853610061073508770L; @@ -31,7 +32,7 @@ } /** - * Returns a clone of this object.<br> + * Returns shallow copy of this object.<br> * <b>NOTE:</b> this method does not clone the entries * @return the cloned object */ @@ -44,6 +45,19 @@ } /** + * Returns copy of this object.<br> + * <b>NOTE:</b> this method clones the entries + * @return the copy object + */ + public AvailabilityProfile copy() { + AvailabilityProfile copy = new AvailabilityProfile(); + for(AvailabilityProfileEntry entry : this){ + copy.add(entry.clone()); + } + return copy; + } + + /** * Returns the entry whose time is closest to the <tt>time</tt> given but * smaller, or whose time is equals to <tt>time</tt> * @param time the time to be used to search for the entry Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2008-03-31 00:27:24 UTC (rev 166) @@ -15,7 +15,7 @@ * @since GridSim Turbo Alpha 0.1 */ -public class AvailabilityProfileEntry { +public class AvailabilityProfileEntry implements Cloneable { private PERangeList ranges_; // the ranges available private double time_; // the time when the ranges will be available @@ -25,16 +25,26 @@ * Creates an instance of @link{ProfileEntry}. * @param time the time associated with this event */ - public AvailabilityProfileEntry(double time){ + public AvailabilityProfileEntry(double time) { time_ = time; ranges_ = new PERangeList(); } /** + * Creates an instance of @link{ProfileEntry}. + * @param time the time associated with this event + * @param ranges the ranges to be used by this entry + */ + public AvailabilityProfileEntry(double time, PERangeList ranges) { + time_ = time; + ranges_ = ranges; + } + + /** * Returns the ranges of free PEs associated with this entry * @return the ranges of free PEs associated with this entry */ - public PERangeList getPERanges(){ + public PERangeList getPERanges() { return ranges_; } @@ -42,14 +52,14 @@ * Adds a range of PEs to the list * @param list the range of PEs */ - public void setPERangeList(PERangeList list){ + public void setPERangeList(PERangeList list) { ranges_ = list; } /** * Clears the list of PE ranges */ - public void clearPERangeList(){ + public void clearPERangeList() { ranges_.clear(); } @@ -57,7 +67,7 @@ * Returns the time associated with this entry * @return the time associated */ - public double getTime(){ + public double getTime() { return time_; } @@ -65,7 +75,7 @@ * Gets the number of PEs associated with this entry * @return the number of PEs */ - public int getNumPE(){ + public int getNumPE() { if(ranges_ == null) return 0; else @@ -76,7 +86,7 @@ * Sets the time associated with this event * @param time the time to be set */ - public void setTime(double time){ + public void setTime(double time) { time_ = time; } @@ -84,7 +94,7 @@ * Increases the number of Gridlets that rely on this entry to mark * their expected completion time or their anchor point */ - public void increaseGridlet(){ + public void increaseGridlet() { numGridlets_++; } @@ -92,7 +102,7 @@ * Decreases the number of Gridlets that rely on this entry to mark * their expected completion time or their anchor point */ - public void decreaseGridlet(){ + public void decreaseGridlet() { numGridlets_--; } @@ -101,14 +111,26 @@ * their expected completion time or their anchor point * @return the number of Gridlets that use this entry */ - public int getNumGridlets(){ + public int getNumGridlets() { return numGridlets_; } /** + * Returns a clone of this object. + * @return a clone of this object. + */ + public AvailabilityProfileEntry clone() { + PERangeList ranges = ranges_ == null ? null : ranges_.clone(); + AvailabilityProfileEntry entry = + new AvailabilityProfileEntry(time_, ranges); + entry.numGridlets_ = numGridlets_; + return entry; + } + + /** * Creates a string representation of this entry */ - public String toString(){ + public String toString() { return "ProfileEntry={time="+ time_ + "; gridlets=" + numGridlets_ + "; " + ( (ranges_!=null) ? ranges_ : "{[]}") + "}"; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-31 00:27:24 UTC (rev 166) @@ -17,6 +17,7 @@ import java.util.Calendar; import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; @@ -113,8 +114,8 @@ // The rating of one PE protected int ratingPE_; - // to order gridlets by potential start time - private OrderGridletByStartTime orderStartTime_; + // heuristic used to order the jobs for backfilling + protected Comparator<SSGridlet> jobOrderHeuristic_; // the last time when the schedule updated was called private double lastScheduleUpdate_; @@ -150,7 +151,7 @@ runningGridlets_ = new LinkedList<SSGridlet>(); queuedGridlets_ = new LinkedList<SSGridlet>(); availProfile_ = new AvailabilityProfile(); - orderStartTime_ = new OrderGridletByStartTime(); + jobOrderHeuristic_ = null; lastScheduleUpdate_ = 0.0D; ratingPE_ = 0; } @@ -203,6 +204,22 @@ } /** + * Sets the heuristic used to order the jobs considered for backfilling + * or when a cancellation takes place + * @param comparator a comparator implementation that defines + * how gridlets are ordered. + * @return <tt>true</tt> if the heuristic was set correctly; + * <tt>false</tt> otherwise. + */ + public boolean setJobOrderingHeuristic(Comparator<SSGridlet> comparator) { + if(comparator == null) + return false; + + jobOrderHeuristic_ = comparator; + return true; + } + + /** * Schedules a new <tt>Gridlet</tt> received by the * <tt>GridResource</tt> entity. * @param gridlet a Gridlet object to be executed @@ -330,7 +347,7 @@ * back to sender, i.e. the <tt>userId</tt>. * * <li> If a Gridlet cannot be found in either execution and - * paused list, then a <tt>null</tt> Gridlet will be send back + * waiting lists, then a <tt>null</tt> Gridlet will be send back * to sender, i.e. the <tt>userId</tt>. * * <li> Once a Gridlet is cancelled, the availability profile @@ -402,6 +419,10 @@ null, gridletId, userId); return; } + + // check whether the Gridlet is running + boolean isRunning = sgl.getStatus() == Gridlet.INEXEC; + sgl.setStatus(Gridlet.CANCELED); //----------------- USED FOR DEBUGGING PURPOSES ONLY ------------------- @@ -411,7 +432,7 @@ //---------------------------------------------------------------------- // remove/update entries of the gridlet in the profile - removeGridlet(sgl); + removeGridlet(isRunning, sgl); // compress the schedule, that is, moves the gridlets forwards if(!sgl.hasReserved()) @@ -425,7 +446,6 @@ //---------------------------------------------------------------------- // sends the Gridlet back to user - sgl.setStatus(Gridlet.CANCELED); sgl.finalizeGridlet(); super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, sgl.getGridlet(), gridletId, userId); @@ -511,7 +531,8 @@ // iterates the waiting queue and for each gridlet, put the ranges // used back in the profile. That is, updates the entries - Collections.sort(queuedGridlets_, orderStartTime_); + if(jobOrderHeuristic_ != null) + Collections.sort(queuedGridlets_, jobOrderHeuristic_); Iterator<SSGridlet> iterQueue = queuedGridlets_.iterator(); while(iterQueue.hasNext()) { @@ -1206,15 +1227,15 @@ /** * This method removes/updates all the entries of a gridlet from the profile * and updates the ranges of current free PEs if the gridlet was in execution. + * @param wasRunning <tt>true</tt> if the gridlet was running; + * <tt>false</tt> otherwise. * @param gridlet the Gridlet to be removed */ - private void removeGridlet(SSGridlet gridlet) { + private void removeGridlet(boolean wasRunning, SSGridlet gridlet) { if(!gridlet.hasReserved()) { - // check whether the Gridlet is running - boolean isRunning = gridlet.getStatus() == Gridlet.INEXEC; // removes the gridlet from the profile - updateEntriesAtProfile(isRunning, gridlet); + updateEntriesAtProfile(wasRunning, gridlet); } } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-03-31 00:27:24 UTC (rev 166) @@ -16,7 +16,6 @@ import java.util.Calendar; import java.util.Collections; -import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; @@ -74,9 +73,6 @@ // Pivot jobs (i.e. the first n jobs in the queue) protected LinkedList<SSGridlet> pivotGridlets_; - - // heuristic used to order the jobs for backfilling - protected Comparator<SSGridlet> jobOrderHeuristic_; // Similarly to the aggressive backfilling in MAUI, the user // can specify how many pivots can be considered when scheduling a job. @@ -110,7 +106,6 @@ super(resourceName, entityName); // initialises local variables pivotGridlets_ = new LinkedList<SSGridlet>(); - jobOrderHeuristic_ = null; maxPivots_ = 1; // default number of pivots is one } @@ -155,21 +150,6 @@ } /** - * Sets the heuristic used to order the jobs considered for backfilling - * @param comparator a comparator implementation that defines - * how gridlets are ordered. - * @return <tt>true</tt> if the heuristic was set correctly; - * <tt>false</tt> otherwise. - */ - public boolean setJobOrderingHeuristic(Comparator<SSGridlet> comparator) { - if(comparator == null) - return false; - - jobOrderHeuristic_ = comparator; - return true; - } - - /** * Sets the maximum number of pivot jobs. Similarly to the aggressive * backfilling in MAUI, the system administrator can specify how many * pivots can be considered when scheduling a job. That is, a job can @@ -240,17 +220,124 @@ } } - /** - * Cancels a Gridlet running or in the waiting queue.<br> - * <b>NOTE: Not implemented YET.</b> + /** + * Cancels a Gridlet running or in the waiting queue. + * This method will search the running and waiting queues. + * The User ID is important as many users might have the same + * Gridlet ID in the lists. If a Gridlet is cancelled and the gridlet was + * either running or was a pivot, then the availability profile is updated. + * After that, the backfilling algorithm is called to check which + * gridlets can be started or scheduled. + * <b>NOTE:</b> + * <ul> + * <li> Before cancelling a Gridlet, this method updates when + * the expected completion time of the Gridlet is. If the + * completion time is smaller than the current time, then + * the Gridlet is considered to be <tt>finished</tt>. + * Therefore the Gridlet cannot be cancelled. + * + * <li> Once a Gridlet has been cancelled, it cannot be resumed + * to execute again since this method will pass the Gridlet + * back to sender, i.e. the <tt>userId</tt>. + * + * <li> If a Gridlet cannot be found in either execution and + * waiting lists, then a <tt>null</tt> Gridlet will be send back + * to sender, i.e. the <tt>userId</tt>. + * </ul> * @param gridletId a Gridlet ID * @param userId the user or owner's ID of this Gridlet * @pre gridletId > 0 * @pre userId > 0 */ public void gridletCancel(int gridletId, int userId) { - System.out.println(super.get_name() + - ".gridletCancel(): not supported at the moment."); + double currentTime = GridSim.clock(); + + // stores the gridlet if found + SSGridlet sgl = null; + boolean found = false; + boolean updateProfile = false; + + // Look for the Gridlet in the running queue + sgl = findSSGridlet(runningGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // if the Gridlet's finish time is smaller than the current + // time or the status is FINISHED, it means that the Gridlet + // has finished, but has not been removed from the running + // queue yet. It will probably be done shortly, + // so just send a null to the user. + if(sgl.getStatus() == Gridlet.SUCCESS || + sgl.getActualFinishTime() <= currentTime){ + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; // return as it is impossible to cancel the Gridlet + } + else{ + // remove from the queue before compressing the schedule + runningGridlets_.remove(sgl); + updateProfile = true; + } + } + + if(!found) { + // Look for the gridlet in the waiting queue + sgl = findSSGridlet(queuedGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // Get the Gridlet from the waiting queue and + // remove from the queue before compressing the schedule + queuedGridlets_.remove(sgl); + + // if start time has been set, then it means that gridlet is + // a pivot. So, we need to remove it from the pivot list + if(sgl.getStartTime() > 0) { + pivotGridlets_.remove(sgl); + updateProfile = true; + } + } + } + + // If the Gridlet could not be found in neither queue, then send a null + // Gridlet to the user and return because there is no need to + // compress the schedule + if(!found) { + System.out.println(super.get_name() + ".gridletCancel():" + + " Cannot find Gridlet #" + gridletId + " for User #" + userId); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; + } + + // check whether the Gridlet is running + boolean isRunning = sgl.getStatus() == Gridlet.INEXEC; + sgl.setStatus(Gridlet.CANCELED); + + //----------------- USED FOR DEBUGGING PURPOSES ONLY ------------------- + + // If a gridlet has been cancelled, then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, sgl); + + //---------------------------------------------------------------------- + + // remove/update entries of the gridlet in the profile + if(updateProfile) { + removeGridlet(isRunning, sgl); + backfillGridlets(currentTime); + + //------------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- + + // Inform the listeners about the new schedule + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //---------------------------------------------------------------------- + } + + // sends the Gridlet back to user + sgl.finalizeGridlet(); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + sgl.getGridlet(), gridletId, userId); } /** @@ -393,8 +480,8 @@ // order jobs according to the ordering heuristic provided. // That is, if one was provided by the user. - if(jobOrderHeuristic_ != null) - Collections.sort(queuedGridlets_, jobOrderHeuristic_); + if(super.jobOrderHeuristic_ != null) + Collections.sort(queuedGridlets_, super.jobOrderHeuristic_); // Start the execution of Gridlets that are queued iter = queuedGridlets_.iterator(); @@ -427,4 +514,21 @@ return gridletStarted; } + + // ------------------------- PRIVATE METHODS ---------------------------- + + /** + * This method removes/updates all the entries of a gridlet from the profile + * and updates the ranges of current free PEs if the gridlet was in execution. + * @param wasRunning <tt>true</tt> if the gridlet was running; + * <tt>false</tt> otherwise. + * @param gridlet the Gridlet to be removed + */ + private void removeGridlet(boolean wasRunning, SSGridlet gridlet) { + if(!gridlet.hasReserved()) { + + // removes the gridlet from the profile + updateEntriesAtProfile(wasRunning, gridlet); + } + } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java 2008-03-31 00:27:24 UTC (rev 166) @@ -10,7 +10,7 @@ * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 */ -public class MPProfileEntry { +public class MPProfileEntry implements Cloneable { // the ranges available private HashMap <Integer, PERangeList> ranges_; // the time when the ranges will be available Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java 2008-03-31 00:27:24 UTC (rev 166) @@ -16,6 +16,7 @@ * @since GridSim Turbo Alpha 0.1 * @see PERangeList * @see CBParallelSpaceShared + * @see EBParallelSpaceShared */ public class PERange implements Cloneable, Comparable<PERange> { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-03-31 00:27:24 UTC (rev 166) @@ -22,6 +22,7 @@ * * @see PERange * @see CBParallelSpaceShared + * @see EBParallelSpaceShared * @see ARParallelSpaceShared */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java 2008-03-31 00:27:24 UTC (rev 166) @@ -15,7 +15,7 @@ private QueuePartitionPredicate predicate_; /** - * Creates a new <tt>Queuepartition</tt> object. + * Creates a new <tt>QueuePartition</tt> object. * @param queueId the partition ID * @param numPE the number of PEs initially assigned to the partition * @param predicate the queue predicate Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2008-03-30 03:49:36 UTC (rev 165) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2008-03-31 00:27:24 UTC (rev 166) @@ -23,6 +23,7 @@ * @see SSGridlet * @see Reservation * @see CBParallelSpaceShared + * @see EBParallelSpaceShared * @see ARParallelSpaceShared */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-30 03:49:30
|
Revision: 165 http://gridsim.svn.sourceforge.net/gridsim/?rev=165&view=rev Author: marcos_dias Date: 2008-03-29 20:49:36 -0700 (Sat, 29 Mar 2008) Log Message: ----------- This update contains better descriptions of the examples, an improved version of the aggressive backfilling policy and changes in the visibility of some methods to improve the reuseability. The aggressive backfilling policy now looks similar to that implemented in the MAUI scheduler, where the system administrator can configure the number of jobs that cannot be delayed when the backfilling algorithm is invoked. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java Removed Paths: ------------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java Modified: branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,23 +1,33 @@ package examples; +import gridsim.turbo.CBMultiplePartitions; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.QueuePartitionPredicate; import gridsim.turbo.SSGridlet; import gridsim.turbo.SSReservation; import gridsim.turbo.ScheduleItem; /** - * Example of queue predicate. This predicate filters - * gridlets according to their runtime + * Example of queue predicate. This predicate filters gridlets and + * advance reservations according to their runtime or duration * * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see QueuePartitionPredicate + * @see EBMultiplePartitions + * @see CBMultiplePartitions */ public class QueuePredicateExample implements QueuePartitionPredicate { - int minRuntime_; - int maxRuntime_; - int resRating_; + int minRuntime_; // the minimum run time for the partition + int maxRuntime_; // the maximum run time for the partition + int resRating_; // the rating of the resource's PEs - /* + /** * Default constructor + * @param minRuntime the minimum run time for the partition + * @param maxRuntime the maximum run time for the partition + * @param rating the rating of the resource's PEs */ public QueuePredicateExample(int minRuntime, int maxRuntime, int rating) { @@ -26,9 +36,12 @@ this.resRating_ = rating; } - /* - * (non-Javadoc) - * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.ScheduleItem) + /** + * This method returns <tt>true</tt> if the item can be scheduled + * using the partition. + * @return <tt>true</tt> if the item can be scheduled + * using the partition; <tt>false</tt> otherwise. + * @see QueuePartitionPredicate#match(gridsim.turbo.ScheduleItem) */ public boolean match(ScheduleItem item) { double runtime = 0; Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-03-30 03:49:36 UTC (rev 165) @@ -19,7 +19,8 @@ /** * This class is an extended version of {@link Workload}. This class - * cancels some gridlets submitted. + * cancels some gridlets submitted. This class has been created only for + * example and debugging purposes. * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 @@ -27,10 +28,12 @@ * @see Workload */ public class WorkloadWithCancellation extends Workload { - private final int NUM_GRIDLETS_BETWEEN_CANCELLATIONS = 50; + + private int numGrlsBetweenCancellations_ = 50; + // value of 1, means that the cancellation will be sent // at the gridlet's submission time + (gridlet duration * 1) - private final double TIME_CANCELLATION = 0.5; + private double timeCancellation_ = 0.5; /** * Create a new {@link WorkloadWithCancellation} object <b>without</b> using @@ -154,6 +157,23 @@ //////////////////////// PRIVATE METHODS /////////////////////// /** + * Set the number of gridlets interval between cancelations. + * @param numGrlsBetweenCancellations the number of gridlets + */ + public void setNumGrlsBetweenCancellations(int numGrlsBetweenCancellations) { + numGrlsBetweenCancellations_ = numGrlsBetweenCancellations; + } + + /** + * Configures the cancellation time of the gridlets. The cancellation time + * of a gridlet will be submission time + (runtime * timeCancellation) + * @param timeCancellation the cancellation time + */ + public void setTimeCancellation(double timeCancellation) { + timeCancellation_ = timeCancellation; + } + + /** * Collects Gridlets sent and stores them into a list. * @pre $none * @post $none @@ -182,12 +202,6 @@ if (data != null && data instanceof Gridlet) { gl = (Gridlet) data; -// if(gl.getGridletStatus() == Gridlet.FAILED) -// System.out.println("Gridlet failed"); -// -// if(gl.getGridletStatus() == Gridlet.CANCELED) -// System.out.println("Gridlet cancelled"); - list_.add(gl); counter++; } @@ -238,10 +252,10 @@ new IO_data(gl, gl.getGridletFileSize(), resID_) ); // check whether a cancellation has to be scheduled or not - int result = gridletID_ % NUM_GRIDLETS_BETWEEN_CANCELLATIONS; + int result = gridletID_ % numGrlsBetweenCancellations_; if(result == 0) { - super.send(super.output, (submitTime + (TIME_CANCELLATION * runTime)), GridSimTags.GRIDLET_CANCEL, - new IO_data(gl, 0, resID_) ); + super.send(super.output, (submitTime + (timeCancellation_ * runTime)), + GridSimTags.GRIDLET_CANCEL, new IO_data(gl, 0, resID_) ); gridletID_++; } } Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-03-30 03:49:36 UTC (rev 165) @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Calendar; import java.util.Enumeration; import java.util.Random; import java.util.zip.GZIPInputStream; @@ -34,65 +33,17 @@ import gridsim.net.SimpleLink; import gridsim.turbo.Reservation; import gridsim.turbo.ReservationRequester; +import gridsim.util.SimReport; +import gridsim.util.Workload; /** - * The main purpose of this class is to create a realistic simulation - * environment where your jobs or Gridlets are competing with others. - * In other words, the grid resource might not be available at certain times. - * In addition, the arrival time of jobs are also captured in the trace file. - * <p> - * This workload class has been modified to simulate advance reservations. - * Some parameters where included to indicate the frequency in which - * advance reservations are made. Additionally, it is possible to specify how - * long in advance the advance reservations are made. - * <p> - * This class is responsible for reading resource traces from a file and - * sends Gridlets to only <tt>one</tt> destinated resource. <br> - * <b>NOTE:</b> - * <ul> - * <li> This class can only take <tt>one</tt> trace file of the following - * format: <i>ASCII text, zip, gz.</i> - * <li> This class can be classified as <b>one grid user entity</b>. - * Hence, you need to incorporate this entity into <tt>numUser</tt> - * during {@link gridsim.GridSim#init(int, Calendar, boolean)} - * <li> If you need to use multiple trace files to submit Gridlets to - * same or different resources, then you need to create multiple - * instances of this class <tt>each with a unique entity name</tt>. - * <li> If size of the trace file is huge or contains lots of traces - * please increase the JVM heap size accordingly by using - * <tt>java -Xmx</tt> option when running the simulation. - * <li> If you are running an experiment using the network extension, - * i.e. the gridsim.net package, then you need to use - * {@link #WorkloadWithReservation(String, double, double, int, String, String, int)} - * instead. - * <li> The default job file size for sending to and receiving from - * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. - * However, you can specify - * the file size by using {@link #setGridletFileSize(int)}. - * <li> A job run time is only for 1 PE <tt>not</tt> the total number of - * allocated PEs. - * Therefore, a Gridlet length is also calculated for 1 PE.<br> - * For example, job #1 in the trace has a run time of 100 seconds - * for 2 processors. This means each processor runs - * job #1 for 100 seconds, if the processors have the same - * specification. - * </ul> - * <p> - * By default, this class follows the standard workload format as specified - * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> - * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> - * However, you can use other format by calling the below methods before - * running the simulation: - * <ul> - * <li> {@link #setComment(String)} - * <li> {@link #setField(int, int, int, int, int)} - * </ul> - * - * @see gridsim.GridSim#init(int, Calendar, boolean) - * @author Marcos Dias de Assuncao (the most of the code came - * from {@link Workload} class) + * This class was created to create jobs and advance reservations based on + * information read from a job trace. Most of the source code has been copied + * from {@link Workload} class. + * + * @see Workload + * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 - * @invariant $none */ public class WorkloadWithReservation extends ReservationRequester { @@ -125,7 +76,6 @@ private long seed_ = 11L*13*17*19*23+1; // TAGS FOR INTERNAL EVENTS - private final int GRIDLET_SUBMIT = 10; private final int RESERVE_RESOURCES = 11; /** @@ -564,6 +514,13 @@ public void body() { System.out.println(); System.out.println(super.get_name() + ".body() :%%%% Start ..."); + + SimReport report = null; + try { + report = new SimReport("report"); + } catch (ParameterException e) { + e.printStackTrace(); + } // create a temp array fieldArray_ = new String[MAX_FIELD]; @@ -680,6 +637,16 @@ list_.add(gl); counter++; returned++; + + if(gl.getGridletStatus() == Gridlet.SUCCESS) { + double runTime = gl.getFinishTime() - gl.getExecStartTime(); + + if(runTime < 1) + runTime = 1; + + double slowdown = (gl.getWaitingTime() + runTime) / runTime; + report.write(gl.getGridletID() + ", " + slowdown); + } } if(counter == gridletID_) @@ -695,6 +662,8 @@ shutdownUserEntity(); terminateIOEntities(); + report.finalWrite(); + System.out.println(super.get_name() + ".body() : %%%% Exit ..."); } Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2008-03-30 03:49:36 UTC (rev 165) @@ -28,6 +28,7 @@ * current time as the starting time * - commits an accepted reservation * - checks the status of a reservation + * - submits gridlets to the resource */ public class ARTest extends ReservationRequester { private GridletList list_; // a list containing new Gridlets @@ -39,7 +40,6 @@ private final int MIN = 60 * SEC; // 1 min in seconds private final int HOUR = 60 * MIN; // 1 hour in minutes private final int DAY = 24 * HOUR; // 1 day in hours - /** * Creates a new grid user entity Modified: branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -85,6 +85,7 @@ // Fourth step: Starts the simulation // GridSim.startGridSimulation(); + // Start Gridsim in debug mode (i.e., it shows the visualiser) GridSim.startGridSimulation(true); //------------------------------------------------ Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with a conservative + * backfilling policy with advance reservation features and with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.ar; @@ -150,6 +159,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // this resource will use a conservative backfilling policy with + // multiple partitions and advance reservation features TResourceCharacteristics resConfig = new TResourceCharacteristics(arch, os, mList, TResourceCharacteristics.ARCB_MULTI_PARTITIONS, @@ -162,15 +173,21 @@ e1.printStackTrace(); } - // creates three partitions, one for small jobs, one for medium size jobs + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -155,6 +155,8 @@ TResourceCharacteristics.AREB_MULTI_PARTITIONS, time_zone, cost); + // this resource will use a aggressive backfilling policy with + // multiple partitions and advance reservation features AREBMultiplePartitions policy = null; try { policy = new AREBMultiplePartitions(name, "Policy", 3); @@ -162,15 +164,21 @@ e1.printStackTrace(); } - // creates three partitions, one for small jobs, one for medium size jobs + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,14 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy with advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. The jobs generated by this class are not + * advance reservations, however. This example has been created for debugging + * purposes. + */ package examples.workload.ar; @@ -143,6 +154,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // Creates the resource characteristics object and inform it that + // the policy to be used is TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy with advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.ar; @@ -150,6 +159,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // Creates the resource characteristics object and inform it that + // the policy to be used is TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,13 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example creates three resources and three workload + * objects. The workloads make advance reservations and submit gridlets + * to the resources. The policy used by the resources is conservative + * backfilling with advance reservation. To test this example, you can use + * one of the traces included in the workloads directory. + */ package examples.workload.ar; @@ -13,9 +23,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.LinkedList; -import java.util.Random; - /** * Test Driver class for this example. This example just tests * the same features provided by the ParallelSpaceShared policy Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,14 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy with advance reservation features. The jobs are + * read from a trace file. The workload object cancels some of the gridlets + * submitted to the resource. This example has been implemented to test + * the cancellation features. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.ar; Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,15 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a workload that submits + * jobs to a grid resource based on the workload model described by Lublin and + * Feitelson in the following paper: + * + * Uri Lublin and Dror G. Feitelson, The Workload on Parallel Supercomputers: + * Modeling the Characteristics of Rigid Jobs. J. Parallel & Distributed + * Comput. 63(11), pp. 1105-1122, Nov 2003. + */ package examples.workload.parallel; Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy without advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.parallel; @@ -15,7 +24,7 @@ /** - * Test Driver class for this example + * Test Driver class for this example. */ public class TurboExample01 { @@ -137,6 +146,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // Create the TResourceCharacteristics object and inform that the + // policy to be used is TResourceCharacteristics.CB_PARALLEL_SPACE_SHARED TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.CB_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,14 +1,22 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with a conservative + * backfilling policy without advance reservation features but with multiple + * partitions. This example creates the policy with only one partition, however. + * This has been done for debugging purposes. The policy should behave like a + * normal conservative backfilling policy when only one partition is created. + * The jobs are read from a trace file. To test this example, you can use one + * of the traces included in the workloads directory. + */ package examples.workload.parallel; -import gridsim.AllocPolicy; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.ResourceCharacteristics; -import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -17,7 +25,6 @@ import java.util.LinkedList; import java.util.Random; - /** * Test Driver class for this example */ @@ -132,7 +139,7 @@ } ////////////////////////////////////////// - // 5. Create a ResourceCharacteristics object that stores the + // 5. Create a TResourceCharacteristics object that stores the // properties of a Grid resource: architecture, OS, list of // Machines, allocation policy: time- or space-shared, time zone // and its price (G$/PE time unit). @@ -141,7 +148,9 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use a conservative backfilling policy but + // with only one partition. Note that we do not have to specify the + // number of partitions, so only one will be created TResourceCharacteristics resConfig = new TResourceCharacteristics(arch, os, mList, TResourceCharacteristics.CB_MULTI_PARTITIONS, Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with a conservative + * backfilling policy without advance reservation features but with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.parallel; @@ -8,7 +17,6 @@ import gridsim.MachineList; import gridsim.ResourceCalendar; import gridsim.turbo.CBMultiplePartitions; -import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -141,7 +149,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use a conservative backfilling policy with + // multiple partitions and without advance reservation features TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.CB_MULTI_PARTITIONS, time_zone, cost); @@ -153,16 +162,22 @@ e1.printStackTrace(); } - // creates three partitions, one for small jobs, one for medium size jobs + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); + ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. double baud_rate = 10000.0; // communication speed Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,14 +1,22 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with an aggressive + * backfilling policy without advance reservation features but with multiple + * partitions. This example creates the policy with only one partition, however. + * This has been done for debugging purposes. The policy should behave like a + * normal aggressive backfilling policy when only one partition is created. + * The jobs are read from a trace file. To test this example, you can use one + * of the traces included in the workloads directory. + */ package examples.workload.parallel; -import gridsim.AllocPolicy; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.ResourceCharacteristics; -import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -17,7 +25,6 @@ import java.util.LinkedList; import java.util.Random; - /** * Test Driver class for this example */ @@ -141,7 +148,9 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use an aggressive backfilling policy (EASY) but + // with only one partition. Note that we do not have to specify the + // number of partitions, so only one will be created TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with an aggressive + * backfilling policy without advance reservation features but with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.parallel; @@ -16,7 +25,6 @@ import java.util.LinkedList; import java.util.Random; - /** * Test Driver class for this example */ @@ -139,7 +147,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use an aggressive backfilling policy with + // multiple partitions and without advance reservation features TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, time_zone, cost); @@ -150,17 +159,23 @@ } catch (Exception e1) { e1.printStackTrace(); } - - // creates three partitions, one for small jobs, one for medium size jobs + + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); + ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. double baud_rate = 10000.0; // communication speed Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with an aggressive + * backfilling policy without advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.parallel; @@ -83,10 +92,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over @@ -137,7 +146,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use an aggressive backfilling policy (EASY) but + // without advance reservations TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,14 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy without advance reservation features. + * This example has beenn implemented to test the job cancellation. The workload + * object created in this example cancels some of the gridlets submitted. The + * jobs are read from a trace file. To test this example, you can use one + * of the traces included in the workloads directory. + */ package examples.workload.parallel; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-30 03:49:36 UTC (rev 165) @@ -906,7 +906,6 @@ private int startReservation(double refTime) { LinkedList<SSReservation> startedReservations = new LinkedList<SSReservation>(); - PERangeList allocatedRanges = new PERangeList(); int numStartedRes = 0; Iterator<SSReservation> iterRes = reservTable_.values().iterator(); @@ -919,8 +918,6 @@ // Start the reservation and update the ranges of // PEs currently available sRes.setStatus(Reservation.STATUS_IN_PROGRESS); - - allocatedRanges.addAll(sRes.getPERangeList().clone()); startedReservations.add(sRes); super.sendInternalEvent(sRes.getActualFinishTime()-refTime, @@ -935,9 +932,6 @@ // the gridlets in the queue that can be started if(numStartedRes > 0) { - // allocates the ranges to the advance reservations - resource_.setPEsBusy(allocatedRanges); - //------------- USED FOR DEBUGGING PURPOSES ONLY ------------------ // notify the listeners @@ -965,9 +959,6 @@ private int finishReservation(double refTime) { int reservationFinished = 0; - // remove all reservations that have already completed - PERangeList releasedRanges = new PERangeList(); - Iterator<SSReservation> iterRes = reservTable_.values().iterator(); while(iterRes.hasNext()) { SSReservation sRes = iterRes.next(); @@ -975,16 +966,12 @@ // Finish the reservation and include ranges in the // list of ranges to be released sRes.setStatus(Reservation.STATUS_FINISHED); - releasedRanges.addAll(sRes.getPERangeList().clone()); reservationFinished++; iterRes.remove(); expiryTable_.put(sRes.getID(), sRes); } } - // returns the ranges to the list of current available ranges - resource_.setPEsAvailable(releasedRanges); - if(reservationFinished > 0) { //------------- USED FOR DEBUGGING PURPOSES ONLY ------------------ @@ -1000,91 +987,6 @@ } /** - * Selects a list of PE ranges able to provide enough PEs to handle - * a reservation or a Gridlet. - * - * @param reqPE the number of PEs - * @param startTime the start time of the reservation / Gridlet<br> - * @param duration the duration of the reservation / Gridlet - * @return an array[2] of Objects as follows if there are enough PEs - * to serve the Gridlet or reservation:<br> - * array[0] the index of the last entry before the finish time - * of the reservation/Gridlet in the availability profile<br> - * array[1] the list of PE ranges<br> - * OR an <tt>null</tt> if a range with enough PEs is not found. - */ - private Object[] checkImmediatePERangesAvailability(int reqPE, - double startTime, double duration) { - - // tail index represents the position which corresponds to the closest - // entry to the gridlet's finish time OR an existing entry whose - // time is equals to the gridlet's or advance reservation's finish time - int tailIndex = -1; - - if(availProfile_.size() == 0) { - // creates the array with the result - Object[] result = new Object[2]; - result[0] = tailIndex; - result[1] = super.selectPERangeList(reqPE, resource_.getFreePERanges()); - return result; - } - - // a pointer to the last entry analysed (described above) - AvailabilityProfileEntry tailEntry = null; - - // NOTE: freePERanges_ does not need to be cloned here as the - // PERangeList.intersection() and selectPERangeList() methods will - // create a new list of ranges with the intersection anyway. - // For immediate gridlets or advance reservations, the start point - // is the current list of PEs available - PERangeList intersectList = resource_.getFreePERanges(); - - // if time is unknown, then make the current time the start time - if(startTime < 0) - startTime = GridSim.clock(); - - // the gridlet's expected finish time - double finishTime = startTime + duration; - - // scan the availability profile until the expected termination - // of the Gridlet to check whether enough PEs will be available - // for the Gridlet. Stop the search if not enough PEs are available - for(AvailabilityProfileEntry entry : availProfile_) { - double entryTime = entry.getTime(); - if(entryTime < startTime) { - continue; - } - else if(entryTime > finishTime) { - break; - } - else { - tailEntry = entry; - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(entryTime < finishTime) { - PERangeList listEntry = entry.getPERanges(); - intersectList = PERangeList.intersection(listEntry, intersectList); - if(intersectList == null || intersectList.getNumPE() < reqPE) - break; - } - } - tailIndex = availProfile_.indexOf(tailEntry); - } - - // return null if the number of PEs available over the required - // time interval is smaller than what the Gridlet/Reservation requires - if(intersectList == null || intersectList.getNumPE() < reqPE) { - return null; - } - - // creates the array with the result - Object[] result = new Object[2]; - result[0] = tailIndex; - result[1] = super.selectPERangeList(reqPE, intersectList); - return result; - } - - /** * Selects a list of PE ranges able to provide enough PEs * to handle a reservation. * @@ -1096,7 +998,7 @@ * of the reservation in the availability profile<br> * array[2] the list of PE ranges<br> */ - private Object[] checkPERangesAvailability(int reqPE, + protected Object[] checkPERangesAvailability(int reqPE, double startTime, double duration) { // the anchor index, the entry in the profile where @@ -1191,183 +1093,6 @@ return result; } - /** - * Allocates a list of PE ranges to a gridlet or reservation - * and updates the availability profile accordingly. - * - * @param tailIndex the index of the entry closest to the - * finish time but whose time is smaller or equals to the finish time - * @param selected the lsit of PE ranges selected - * @param startTime the start time of the Gridlet / reservation - * @param finishTime the finish time of the Gridlet / reservation - */ - private void allocateImmediatePERanges(int tailIndex, - PERangeList selected, - double startTime, double finishTime) { - - AvailabilityProfileEntry newEntryAfterTail = null; - - // if the time of the entry at (tailIndex) is equals to - // the gridlet finish time, then a new entry in the profile - // is not needed. In this case, the entry at (tailIndex) - // is updated to show that one more gridlet relies on the entry - // to represent its completion time. This reduces the number of - // entries in the availability profile - boolean addEntryAfterTail = true; - - if(tailIndex == -1) { - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(resource_.getFreePERanges().clone()); - tailIndex++; - } - else { - // get the tail entry (that is, the closest entry - // to the finish time - AvailabilityProfileEntry tailEntry = - availProfile_.get(tailIndex); - - if (tailEntry.getTime() == finishTime) { - addEntryAfterTail = false; - tailEntry.increaseGridlet(); - } - // If a new entry is required, then add it to the profile - else { - - // Gathers the information that must be added at the profile after - // the tail entry, if needed - PERangeList listTail = tailEntry.getPERanges().clone(); - - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(listTail); - tailIndex++; - } - } - - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - - // Update entries of the profile - for(int index=0; index<tailIndex; index++) { - AvailabilityProfileEntry entry = availProfile_.get(index); - - PERangeList uptList = - PERangeList.difference(entry.getPERanges(), selected); - entry.setPERangeList(uptList); - } - - // subtract the selected ranges from the currently free ranges - resource_.setPEsBusy(selected); - - } - - /** - * Allocates a list of PE ranges to a gridlet or reservation and updates the - * availability profile accordingly - * - * @param anchorIndex the index of the anchor that contains the - * Gridlet's start time - * or the place where the new anchor (if needed) will be placed - * @param tailIndex the index of the entry closest to the finish time but - * whose time is smaller or equals to the finish time - * @param selected the list of PE ranges selected - * @param startTime the start time of the Gridlet / reservation - * @param finishTime the finish time of the Gridlet / reservation - */ - private void allocatePERanges(int anchorIndex, int tailIndex, - PERangeList selected, double startTime, - double finishTime) { - - AvailabilityProfileEntry newEntryAfterTail = null; - AvailabilityProfileEntry newEntryAfterAnchor = null; - - // if the time of the entry at (tailIndex) is equals to - // the gridlet finish time, then a new entry in the profile - // is not needed. In this case, the entry at (tailIndex) - // is updated to show that one more gridlet relies on the entry - // to represent its completion time. This reduces the number of - // entries in the availability profile - boolean addEntryAfterTail = true; - - // if the time of the entry at (anchor) is equals to - // the gridlet finish time, then a new entry in the profile - // is not needed. In this case, the entry at (anchorIndex) - // is updated to show that one more gridlet relies on the entry - // to represent its completion time. This reduces the number of - // entries in the availability profile. - boolean addEntryAfterAnchor = false; - - if (tailIndex > -1) { - AvailabilityProfileEntry tailEntry = availProfile_.get(tailIndex); - - if (tailEntry.getTime() == finishTime) { - addEntryAfterTail = false; - tailEntry.increaseGridlet(); - } - // If a new entry is required, then created it to be added - // to the profile - else { - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(tailEntry.getPERanges().clone()); - tailIndex++; - } - } - else { - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(resource_.getFreePERanges().clone()); - tailIndex++; - } - - if (anchorIndex > -1) { - AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); - - double anchorTime = anchorEntry.getTime(); - if ( anchorTime < startTime ) { - addEntryAfterAnchor = true; - // Creates a new entry to be added to the profile - newEntryAfterAnchor = new AvailabilityProfileEntry(startTime); - newEntryAfterAnchor.setPERangeList(anchorEntry.getPERanges().clone()); - // increment the position where the new anchor will be added - anchorIndex++; - } - else if (anchorTime == startTime) { - anchorEntry.increaseGridlet(); - } - } - else { - addEntryAfterAnchor = true; - - // Creates a new entry to be added to the profile - newEntryAfterAnchor = new AvailabilityProfileEntry(startTime); - newEntryAfterAnchor.setPERangeList(resource_.getFreePERanges().clone()); - // increment the position where the new anchor will be added - anchorIndex++; - } - - if(addEntryAfterAnchor) { - availProfile_.add(anchorIndex, newEntryAfterAnchor); - tailIndex++; - } - - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - - // Update entries of the profile - if(tailIndex > -1) { - for(int index=anchorIndex; index<tailIndex; index++){ - AvailabilityProfileEntry entry = availProfile_.get(index); - PERangeList uptList = - PERangeList.difference(entry.getPERanges(), selected); - entry.setPERangeList(uptList); - } - } - } - // ---------------------- PROTECTED METHODS ------------------------ /** @@ -1390,7 +1115,11 @@ itemsFinished += super.finishRunningGridlets(currentTime); // remove past entries from the availability profile - availProfile_.removePastEntries(currentTime); + AvailabilityProfileEntry currentStatus = + availProfile_.removePastEntries(currentTime); + if(currentStatus != null) { + resource_.resetFreePERanges(currentStatus.getPERanges()); + } // starts the advance reservations itemsStarted = startReservation(currentTime); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-30 03:49:36 UTC (rev 165) @@ -51,7 +51,7 @@ * smaller, or whose time is equals to <tt>time</tt>; <tt>null</tt> if * not found. */ - protected AvailabilityProfileEntry getPrecedingEntry(double time) { + public AvailabilityProfileEntry getPrecedingEntry(double time) { Iterator<AvailabilityProfileEntry> it = super.iterator(); AvailabilityProfileEntry preceding = null; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-30 03:49:36 UTC (rev 165) @@ -639,31 +639,21 @@ */ protected int finishRunningGridlets(double currentTime) { int itemsFinished = 0; - boolean reserved; // to indicate whether the gridlet refers to a reserv. - // remove all Gridlets that have already completed from - // the queue of running Gridlets - PERangeList releasedRanges = new PERangeList(); - // iterates the list to check what has finished Iterator<SSGridlet> iter = runningGridlets_.iterator(); while (iter.hasNext()) { SSGridlet gridlet = iter.next(); - reserved = gridlet.hasReserved(); // as gridlets are removed from running queue once they finish // time is smaller than current time, then testing the time // is enough. There's no need to check status if(gridlet.getActualFinishTime() <= currentTime) { // Update the list of ranges released - if(!reserved) { - releasedRanges.addAll(gridlet.getPERangeList().clone()); - } gridletFinish(gridlet, Gridlet.SUCCESS); iter.remove(); itemsFinished++; } } - resource_.setPEsAvailable(releasedRanges); return itemsFinished; } @@ -676,20 +666,14 @@ */ protected int startQueuedGridlets(double currentTime) { int gridletStarted = 0; - boolean reserved; // to indicate whether the gridlet refers to a reserv. // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than reference time - PERangeList allocatedRanges = new PERangeList(); Iterator<SSGridlet> iter = queuedGridlets_.iterator(); while (iter.hasNext()) { SSGridlet gridlet = iter.next(); // check whether there is a reservation for this gridlet - reserved = gridlet.hasReserved(); if(gridlet.getStartTime() <= currentTime) { - // Update the list of ranges allocated - if(!reserved) - allocatedRanges.addAll(gridlet.getPERangeList()); runningGridlets_.add(gridlet); iter.remove(); @@ -702,7 +686,6 @@ } } - resource_.setPEsBusy(allocatedRanges); return gridletStarted; } @@ -720,7 +703,11 @@ itemsFinished = finishRunningGridlets(currentTime); // remove past entries from the availability profile - availProfile_.removePastEntries(currentTime); + AvailabilityProfileEntry currentStatus = + availProfile_.removePastEntries(currentTime); + if(currentStatus != null) { + resource_.resetFreePERanges(currentStatus.getPERanges()); + } // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than current time @@ -771,7 +758,7 @@ * @pre sgl != null * @post $none */ - private boolean startGridlet(SSGridlet sgl) { + protected boolean startGridlet(SSGridlet sgl) { int reqPE = sgl.getNumPE(); // calculate the execution time of the Gridlet @@ -821,7 +808,7 @@ * elements allocated. * @param sgl the resource gridlet */ - private void enqueueGridlet(SSGridlet sgl){ + protected void enqueueGridlet(SSGridlet sgl){ int reqPE = sgl.getNumPE(); // calculate the execution time of the Gridlet @@ -856,23 +843,24 @@ sgl.setActualFinishTime(finishTime); } - /** + /** * Selects a list of PE ranges able to provide enough PEs to handle - * a Gridlet. + * a reservation or a Gridlet. + * * @param reqPE the number of PEs - * @param startTime the start time of the Gridlet<br> - * @param duration the duration of the Gridlet + * @param startTime the start time of the reservation / Gridlet<br> + * @param duration the duration of the reservation / Gridlet * @return an array[2] of Objects as follows if there are enough PEs * to serve the Gridlet or reservation:<br> * array[0] the index of the last entry before the finish time - * of the Gridlet in the availability profile<br> + * of the reservation/Gridlet in the availability profile<br> * array[1] the li... [truncated message content] |
From: <xu...@us...> - 2008-03-28 11:15:30
|
Revision: 164 http://gridsim.svn.sourceforge.net/gridsim/?rev=164&view=rev Author: xulio Date: 2008-03-28 04:14:42 -0700 (Fri, 28 Mar 2008) Log Message: ----------- BBModel - Need check the Simply version Allocs - Extended checks are necesary Added Paths: ----------- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBModel.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelGridlet.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelTask.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBTaskModel.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBModel.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBTaskModel.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelGridlet.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelTask.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimpleBBModel.java branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimplifyResBBParallelGridlet.java branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/ branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingAlloc.java branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingL1Alloc.java branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/EASYBackFillingAlloc.java branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/FIFOAlloc.java branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/FirstFitAlloc.java Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBModel.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBModel.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBModel.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,25 @@ +package gridsim.parallel.BBModel; + + +public interface BBModel { + + public double getCommunication(); + + public boolean nextState(); + public State getState(); + public void reset(); + + public enum State{ + COMMUNICATION,COMPUTATION,FINISHED + } + + public double getRemainingData(); + public int getRemainingCommunications(); + + public BBTaskModel[] getTaskModel(); + + public double getTotalLength(); +// public boolean isCheckpoint(); + + public void backToLastCheckpoint(); +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelGridlet.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelGridlet.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelGridlet.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,239 @@ +package gridsim.parallel.BBModel; + + +import gridsim.Gridlet; +import gridsim.ParameterException; +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ParallelGridlet; +import gridsim.parallel.PerformanceModeledGridlet; +import gridsim.parallel.ResParallelGridlet; +import gridsim.parallel.innacuracy.InaccuracyModel; + +/** + * This model consider a parallel application as a group of tasks that interact + * among them. + * + * Each task is characterised by a sequence of computations and communications. + * + * + * In this model, communications are supposed to be global, and with + * implicit barriers, then all tasks are executed in a synchronised way. + * + * With this approach, the complexity of the simulation, and the memory + * requirements do not increase noticeably the cost of the sequential + * simulation itself. + * + * @author Xulio Lopez + * + */ + +public class BBParallelGridlet extends ParallelGridlet implements PerformanceModeledGridlet{ + + /** + * Stores asociated tasks to this ParallelGridlet + */ + private BBParallelTask[] tasks; + + /** + * Transfered data in each communication in bits. + */ + // private double[] gridletCommData; + private BBModel model; + + /** + * Allocates a new Gridlet object. The Gridlet length, input and output file + * sizes should be greater than or equal to 1. + * + * TODO Explain basic model of flops/coms + * + * @param gridletID + * the unique ID of this Gridlet + * @param gridletLength + * the length or size (in MI) of this Gridlet to be executed in a + * GridResource + * @param gridletFileSize + * the file size (in byte) of this Gridlet <tt>BEFORE</tt> + * submitting to a GridResource + * @param gridletOutputSize + * the file size (in byte) of this Gridlet <tt>AFTER</tt> + * finish executing by a GridResource + * @param record + * record the history of this object or not + * @param numPE + * the number of PEs required to run this Gridlet + * @param gridletCommunications + * the number of communications of this Gridlet to be executed in + * a ParallelGridResource. + * @param gridletCommData + * the data size (in byte) transmited in each communication (same + * for all) + * @throws ParameterException + * Invalid number of communications, data comunicated or PE. + * @pre gridletID >= 0 + * @pre gridletLength >= 0.0 + * @pre gridletFileSize >= 1 + * @pre gridletOutputSize >= 1 + * @pre numPE >= 1 + * @pre gridletCommunications >= 0 + * @pre gridletCommData >= 0.0 + * @post $none + */ + public BBParallelGridlet(int gridletID, double gridletLength, + long gridletFileSize, long gridletOutputSize, boolean record, + int numPE, int gridletCommunications, double gridletCommData) + throws ParameterException { + super(gridletID, gridletLength, gridletFileSize, gridletOutputSize, + record); + if (!this.setNumPE(numPE)) + throw new ParameterException("Invalid number of PE"); + SimpleBBModel smodel = new SimpleBBModel(gridletLength, + gridletCommunications, gridletCommData, numPE); + model = smodel; + tasks = new BBParallelTask[numPE]; + for (int i = 0; i < numPE; i++) + tasks[i] = new BBParallelTask(smodel); + + /* + * if(numPE>1){ if(gridletCommunications<0) throw new + * ParameterException("Invalid number of Communications"); + * if(gridletCommData<0) throw new ParameterException("Invalid amount + * of comData"); //Create only a copy because reduce memory + * requirements, due to it is only read array. double[] copy = new + * double[gridletCommunications+1]; //TODO Explain the basic model + * if(gridletCommunications>1){ double + * step=gridletLength/gridletCommunications; if(gridletCommunications>2) + * Arrays.fill(copy,1,gridletCommunications,step); + * copy[0]=copy[gridletCommunications]=step*0.5; }else + * copy[0]=gridletLength; for(int i=0;i<numPE;i++) tasks[i]=new + * ComplexBBParallelTask(copy); //All comms with the same amount of + * transfered data this.gridletCommData = new + * double[gridletCommunications]; + * Arrays.fill(this.gridletCommData,gridletCommData); }else { //TODO + * Search a correct way of notificate this. if(gridletCommunications>0) + * System.err.println("Ignore comms in gridlet "+this.getGridletID()+" + * because is processed on one processor"); tasks[0]=new + * ComplexBBParallelTask(new double[]{gridletLength}); + * this.gridletCommData = new double[0]; } fixTaskInternalID(tasks); + */ + } + + public BBParallelGridlet(int gridletID, BBModel model, + long gridletFileSize, long gridletOutputSize, boolean record) + throws ParameterException { + super(gridletID, model.getTotalLength(), gridletFileSize, gridletOutputSize, record); + this.model = model; + BBTaskModel[] tasksModel = model.getTaskModel(); + if (!this.setNumPE(tasksModel.length)) + throw new ParameterException("Invalid number of PE"); + tasks = new BBParallelTask[tasksModel.length]; + for (int i = 0; i < tasks.length; i++) + tasks[i] = new BBParallelTask(tasksModel[i]); + } + + /** + * Allocates a new Gridlet object. The Gridlet length, input and output file + * sizes should be greater than or equal to 1. By default this constructor + * sets the history of this object. + * + * @param gridletID + * the unique ID of this Gridlet + * @param gridletLength + * the length or size (in MI) of this Gridlet to be executed in a + * GridResource + * @param gridletFileSize + * the file size (in byte) of this Gridlet <tt>BEFORE</tt> + * submitting to a GridResource + * @param gridletOutputSize + * the file size (in byte) of this Gridlet <tt>AFTER</tt> + * finish executing by a GridResource + * @param numPE + * the number of PEs required to run this Gridlet + * @param gridletCommunications + * the number of communications of this Gridlet to be executed in + * a ParallelGridResource. + * @param gridletCommData + * the data size (in byte) transmited in each communication (same + * for all) + * @throws ParameterException + * Invalid number of communications, data comunicated or PE. + * @pre gridletID >= 0 + * @pre gridletLength >= 0.0 + * @pre gridletFileSize >= 1 + * @pre gridletOutputSize >= 1 + * @pre numPE >= 1 + * @pre gridletCommunications >= 0 + * @pre gridletCommData >= 0.0 + * @post $none + * + * @see BBParallelGridlet (int, double, long, long, boolean, int, int, + * double) + */ + public BBParallelGridlet(int gridletID, double gridletLength, + long gridletFileSize, long gridletOutputSize, int numPE, + int gridletCommunications, double gridletCommData) + throws ParameterException { + this(gridletID, gridletLength, gridletFileSize, gridletOutputSize, + true, numPE, gridletCommunications, gridletCommData); + } + + public BBParallelGridlet(int gridletID, BBModel model, + long gridletFileSize, long gridletOutputSize) + throws ParameterException { + this(gridletID, model, gridletFileSize, gridletOutputSize, true); + } + + /** + * Generates a ParallelGridlet based in a Gridlet. It suposes that comms are + * null. + * + * @param gl + * Gridlet to be enveloped + * @throws ParameterException + * @see ParallelGridlet (int, long, long, int, double[][], double[]) + */ + public BBParallelGridlet(Gridlet gl) throws ParameterException { + this(gl.getGridletID(), new SimpleBBModel(gl.getGridletLength(), 0, + 0, gl.getNumPE()), gl.getGridletFileSize(), gl + .getGridletOutputSize()); + this.setUserID(gl.getUserID()); + // TODO Auto-generated constructor stub + } + + /** + * It's necessary to give acceces to this information only to + * ResParallelGridlet. + * + * @return A reference (not a copy) to communication vector. + */ + /* + * protected double[] getCommData() { return gridletCommData; } + */ + + /** + * Generates a ResBBParallelGridlet associated to this BBParaleleGridlet + * + * @param internalNet + * internal network model of the GridResource where the + * ResGridlet will be processed + * @see gridsim.parallel.ParallelGridlet#generateResParallelGridlet(InternalNetworkModel) + */ + @Override + public ResParallelGridlet generateResParallelGridlet( + InternalNetworkModel internalNet) { + // TODO Auto-generated method stub + ResBBParallelTask[] resTasks = new ResBBParallelTask[tasks.length]; + for (int i = 0; i < resTasks.length; i++) + resTasks[i] = new ResBBParallelTask(tasks[i]); + return new ResBBParallelGridlet(this, resTasks, internalNet,model); + } + +/* public double calculateEstimatedTime(InternalNetworkModel net, int MIPSrating) { + // TODO Auto-generated method stub + return model.getTotalLength()/MIPSrating/tasks.length+net.getAssociatedCommunicationTime(model.getRemainingData(),model.getRemainingCommunications(),tasks.length); + }*/ + public double calculateEstimatedTime(InternalNetworkModel net, int MIPSrating,InaccuracyModel inModel) { + return inModel.getNextError( + model.getTotalLength()/MIPSrating/tasks.length+net.getAssociatedCommunicationTime(model.getRemainingData(),model.getRemainingCommunications(),tasks.length)); + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelTask.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelTask.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBParallelTask.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,45 @@ +package gridsim.parallel.BBModel; + + +import gridsim.parallel.ParallelTask; + + +/** + * Each ParallelGridlet is divided in Tasks. Each task is executed only in a PE. + * The task has its length, and how much has been processed when a gridlet is migrated. + * A task stored the last finished communication point and the finish mips since the last communication. + * @author Xulio L�pez + */ +public class BBParallelTask extends ParallelTask{ + + /** finished mips after the last synchronized point */ + private double finishedMipsSoFar=0.0d; + /** internal id assigned in ParallelGridlet synchronized with ResParallelTasks */ + private BBTaskModel model; + /** + * Creates a instance of a ParallelTask + * @param gridletTasksLength !!Warning. Not a copy, a reference to original, because is marked as final. + */ + public BBParallelTask(BBTaskModel model) { + this.model=model; + } + + /** + * Saves the progress state of this task, which is necessary to allow a task migration. + * @param finishedLength computations(MIPS/FLOPS) finished after the last communication + */ + public void setTaskRemainingSoFar(double finishedLength) { + finishedMipsSoFar = finishedLength; + } + /** + * Gets the progress state of this task, which is necessary to allow a task migration. + * @param finishedLength computations(MIPS/FLOPS) finished after the last communication + */ + public double getTaskRemainingSoFar() { + return finishedMipsSoFar; + } + + public BBTaskModel getModel() { + return model; + } +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBTaskModel.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBTaskModel.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/BBTaskModel.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,15 @@ +package gridsim.parallel.BBModel; + +import gridsim.parallel.BBModel.BBModel.State; + +public interface BBTaskModel { + + public abstract double getComputation(); + + public abstract State getState(); + + //to forecast + public abstract double getRemainingComputations(); + public boolean isCheckpoint(); + +} \ No newline at end of file Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBModel.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBModel.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBModel.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,122 @@ +package gridsim.parallel.BBModel; + +import java.util.Arrays; + +public class MatrixBBModel implements BBModel { + private double commData[]; + + private BBTaskModel[] tasksModel; + + private double remainingData; + + private int steps, currentStep; + + private State state; + + private double totalLength; + + public MatrixBBModel(double[][] gridletTaskLength, + double[] gridletCommData) { + this.commData = gridletCommData; + tasksModel=new BBTaskModel[gridletTaskLength.length]; + for (int i = 0; i < gridletTaskLength.length; i++) + tasksModel[i]=new MatrixBBTaskModel(gridletTaskLength[i],this); + steps = 2 * gridletCommData.length + 1; + currentStep = 0; + totalLength=0; + for(int i=0;i<gridletTaskLength.length;i++) + for(int j=0;j<gridletTaskLength[i].length;j++) + totalLength+=gridletTaskLength[i][j]; + + state = State.COMPUTATION; + // TODO Auto-generated constructor stub + + remainingData = 0; + for (int i = 0; i < gridletCommData.length; i++) + remainingData += gridletCommData[i]; + } + public MatrixBBModel(double[] gridletTaskLength, + double[] gridletCommData,int tasks) { + this.commData = gridletCommData; + tasksModel=new BBTaskModel[tasks]; + Arrays.fill(tasksModel,new MatrixBBTaskModel(gridletTaskLength,this)); + steps = 2 * gridletCommData.length + 1; + currentStep = 0; + totalLength=0; + for(int i=0;i<gridletTaskLength.length;i++) + totalLength+=gridletTaskLength[i]; + totalLength*=tasks; + + state = State.COMPUTATION; + // TODO Auto-generated constructor stub + + remainingData = 0; + for (int i = 0; i < gridletCommData.length; i++) + remainingData += gridletCommData[i]; + } + + public boolean nextState() { + currentStep++; + if (currentStep < steps) { + if (currentStep % 2 == 0) { + state = State.COMPUTATION; + } else { + state = State.COMMUNICATION; + remainingData -= commData[currentStep / 2]; + // TODO Fix round errors -> need to be 0; + } + return true; + } else { + state = State.FINISHED; + return false; + } + } + + + public double getCommunication() { + return ( state == State.COMMUNICATION ) ? commData[currentStep / 2] : 0; + } + + + public State getState() { + return state; + } + + + + public double getRemainingData() { + // TODO Auto-generated method stub + return remainingData; + } + + public int getRemainingCommunications() { + // TODO Auto-generated method stub + return commData.length - (1 + currentStep) / 2; + } + + public void reset() { + // TODO Auto-generated method stub + currentStep = 0; + for (int i = 0; i < commData.length; i++) + remainingData -= commData[i]; + } + + public int getComputationStep() { + // TODO Auto-generated method stub + return currentStep/2; + } + + public BBTaskModel[] getTaskModel() { + return tasksModel; + } + public double getTotalLength() { + // TODO Auto-generated method stub + return totalLength; + } + + public void backToLastCheckpoint() { + // TODO Auto-generated method stub + System.err.println("Checkpointing in Matrix BBModel is not implemented yet"); + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBTaskModel.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBTaskModel.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/MatrixBBTaskModel.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,39 @@ +package gridsim.parallel.BBModel; + +import gridsim.parallel.BBModel.BBModel.State; + +public class MatrixBBTaskModel implements BBTaskModel { + private double[] computations; + private MatrixBBModel model; + + public MatrixBBTaskModel(double[] taskLength,MatrixBBModel model) { + computations=taskLength; + this.model=model; + // TODO Auto-generated constructor stub + } + + public double getComputation() { + if (model.getState()== State.COMPUTATION) + return computations[model.getComputationStep()]; + else + return 0; + } + + public State getState() { + return model.getState(); + } + + public double getRemainingComputations() { + double remainingComputations=0.0; + for(int i=model.getComputationStep()+1;i<computations.length;i++) + remainingComputations+=computations[i]; + // TODO Auto-generated method stub + return remainingComputations; + } + + public boolean isCheckpoint() { + // TODO Auto-generated method stub + return false; + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelGridlet.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelGridlet.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelGridlet.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,142 @@ +package gridsim.parallel.BBModel; + + +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ResParallelGridlet; + +public class ResBBParallelGridlet extends ResParallelGridlet { + + private double remainCommTime = -1.0; + + private double actualCommTime; + private ResBBParallelTask[] resourceTasks; + BBModel model; + + public ResBBParallelGridlet(BBParallelGridlet pgridlet, + ResBBParallelTask[] resTasks, InternalNetworkModel internalNet, BBModel model) { + super(pgridlet, resTasks,internalNet); + this.model=model; + this.resourceTasks=resTasks; + //FIXME <-this is only to test algorims + } + + public double updateGridletSimulationAdvance(double localLoad, double timeSpan) { + //ResParallelTask task; + boolean computationsFinished; + double lessTime; + double timeToSpent = timeSpan; + double searchTime,commTime; + double avaliableLoad=1 - localLoad; + // Updates the Gridlet length that is currently being executed + /*if (commPoint < 0) { + for (int i = 0; i < resourceTasks.length; i++) { + task = resourceTasks[i]; + task.updateTaskFinishedSoFar(avaliableLoad,timeToSpent); + } + } else*/ + while (timeToSpent > 0) { + switch(model.getState()){ + case COMMUNICATION: + if (remainCommTime < 0) + remainCommTime = internalNet.getAssociatedCommunicationTime(model.getCommunication(),getNumPE()); + if (remainCommTime > timeToSpent) { + remainCommTime -= timeToSpent; + pushdCommTime(timeToSpent); + timeToSpent = 0.0; + } else { + pushdCommTime(remainCommTime); + timeToSpent -= remainCommTime; + commTime=popdCommTime(); + for (int i = 0; i < resourceTasks.length; i++) + resourceTasks[i].finishCommPoint(commTime); + model.nextState(); + remainCommTime = -1.0; + } + break; + case COMPUTATION: + { + searchTime = timeToSpent; + computationsFinished = true; + for (int i = 0; i < resourceTasks.length; i++) { + // compoint deberia ser interno a task + lessTime = resourceTasks[i].updateTaskFinishedSoFar( + avaliableLoad, timeToSpent); + if (lessTime >= 0.0) { + searchTime = Math.min(searchTime, lessTime); + } else { + computationsFinished = false; + searchTime = 0.0; + } + } + if(computationsFinished) model.nextState(); + timeToSpent = searchTime; + break; + } + case FINISHED: + return timeToSpent; + default: + break; + } + } + return -1.0; + } + + // FIXME �Is really necesary?(To move not, but for a pause gridlet can be? + public void resetComm() { +// double lostCommTime = remainCommTime; +// return lostCommTime; + remainCommTime = -1.0; + } + + //FIXME take care of different statistics times + @Override + public void backToLastCheckpoint() { + remainCommTime = -1.0; + for(ResBBParallelTask rbpt:resourceTasks) + rbpt.backToLastCheckpoint(); + model.backToLastCheckpoint(); + } + + private void pushdCommTime(double execTime) { + actualCommTime += execTime; + } + + //NOTE: If the gridlet is canceled in a comm state, this time is not updated in the tasks. Change it? + private double popdCommTime() { + double time = actualCommTime; + actualCommTime = 0.0; + return time; + } + + /*public double getForecastFinishTime(InternalNetworkModel internalNet){ + //TODO Check if exist some problem usind directly MIPSRating without a function call + return super.getForecastFinishTime(); + }*/ + /** + * Gets a forecast finish time of the task. + * @return estimated Tasks's finish time. + */ + public double getForecastFinishTime() + { + double commTime=internalNet.getAssociatedCommunicationTime(model + .getRemainingData(), model.getRemainingCommunications(), getNumPE()); + if (model.getState()==BBModel.State.COMMUNICATION){ + if(remainCommTime < 0) + remainCommTime += internalNet.getAssociatedCommunicationTime(model.getCommunication(),getNumPE()); + commTime=remainCommTime; + } + /* if(commData.length>0) + for (int i=commPoint;i<commData.length;i++) + commTime+=internalNet.getAssociatedCommunicationTime(commData[i],getNumPE()); + */ return super.getForecastFinishTime()+commTime; + } + + @Override + protected boolean isFinished() { + return this.model.getState().equals(BBModel.State.FINISHED); + } + + + + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelTask.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelTask.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/ResBBParallelTask.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,169 @@ +package gridsim.parallel.BBModel; + + +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ParallelGridlet; +import gridsim.parallel.ResParallelTask; + +public class ResBBParallelTask extends ResParallelTask { + + /** Internal asocitated task */ + private BBParallelTask task; + + /** Base offset syncronization point in the execution */ + // private ComplexBBParallelTask task; + private double completedMIPS; + + BBTaskModel model; + + private int internalCommPoint; + + private double MIPSRating; + + /* + * public ResSimpleBBParallelTask(SimpleBBModel model, double completedMIPS) { // + * TODO Auto-generated constructor stub // this.task=task; + * this.completedMIPS = completedMIPS; this.model = model; // + * remaining=task.getRemaingTaskLenght(); // + * baseCommPoint=task.getfinishedCommSoFar(); } + */ + + public ResBBParallelTask(BBParallelTask task) { + this.task = task; + this.completedMIPS = task.getTaskRemainingSoFar(); + model = task.getModel(); + // TODO Auto-generated constructor stub + } + + @Override + /** + * This method is called when the execution of this task in this resource is + * finished. All data ought be fixed to the associated task. + */ + public void finalizeTask() { + task.setTaskRemainingSoFar(completedMIPS); + // System.out.println("Overhead: " + overhead + "\t Inhead: " + inhead + + // "\t Underhead: " + underhead); + } + + // TODO (all time or only time until next communication?) + public double getRemainingLength() { + // Remaining Gridlet length can't be negative number. This can be + // happening when this.updateGridletFinishedSoFar() keep calling. + if (model.getState() == BBModel.State.FINISHED) + return 0.0; + else if (model.getState() == BBModel.State.COMPUTATION) + return model.getRemainingComputations() + model.getComputation() + - completedMIPS; + else + return model.getRemainingComputations(); + } + + public void finishCommPoint(double comTime) { + completedMIPS = 0.0; + internalCommPoint++; + if (model.isCheckpoint()) + pushdTaskTime(comTime, + ParallelGridlet.ParallelTaskState.chk_communication); + else + pushdTaskTime(comTime, + ParallelGridlet.ParallelTaskState.communication); + } + + + //Opional implementation - selected the other becouse in parallel programing, seems to be more probable + @SuppressWarnings("unused") + private double updateTaskFinishedSoFarV2(double avaliableCPU, + double timeSpan) { + // int comPoint) { + // TODO check speed of this structure ,another way? + // double stopPoint = length[] - maxFlops; + double rating = avaliableCPU * MIPSRating; + // internalCommPoint=comPoint-baseCommPoint; + double remaining = model.getComputation() - completedMIPS; + if (remaining <= 0) + return timeSpan; + double tryOps = rating * timeSpan; + if (remaining > tryOps) { + completedMIPS += tryOps; + fixExecTime(timeSpan); + // underhead++; + return -1.0; + } else if (remaining == tryOps) { + // remaining=0.0; + completedMIPS = model.getComputation(); + fixExecTime(timeSpan); + return 0.0; + } else { + double timeSpent = remaining / rating; + fixExecTime(timeSpent); + completedMIPS = model.getComputation(); + // remaining=0.0; + // overhead++; + return timeSpan - timeSpent; + } + } + + private void fixExecTime(double time) { + if (model.isCheckpoint()) + pushdTaskTime(time, + ParallelGridlet.ParallelTaskState.chk_execution); + else + pushdTaskTime(time, ParallelGridlet.ParallelTaskState.execution); + + } + + public double updateTaskFinishedSoFar(double avaliableCPU, double timeSpan) { + // int comPoint) { + // TODO check speed of this structure ,another way? + double rating = avaliableCPU * MIPSRating; + // internalCommPoint=comPoint-baseCommPoint; + double remaining = model.getComputation() - completedMIPS; + if (remaining <= 0) + return timeSpan; + double timeSpent = remaining / rating; + if (timeSpent < timeSpan) { + completedMIPS = model.getComputation(); + // remaining = 0.0; + fixExecTime(timeSpent); + // underhead++; + return timeSpan - timeSpent; + } else if (timeSpent > timeSpan) { + // remaining -= rating * timeSpan; + completedMIPS += rating * timeSpan; + fixExecTime(timeSpan); + // overhead++; + return -1.0; + } else { + // remaining = 0.0; + completedMIPS = model.getComputation(); + fixExecTime(timeSpent); + // inhead++; + return 0.0; + } + } + + @Override + public int getCommsNumber() { + // TODO Auto-generated method stub + return internalCommPoint; + } + + @Override + public double getForecastFinishTime(InternalNetworkModel internalNet, + int tasks) { + return getRemainingLength() / this.MIPSRating; + } + + public void backToLastCheckpoint() { + // TODO fix statitistical times + completedMIPS=0d; + } + + @Override + protected void setMIPSRating(int rating) { + MIPSRating=rating; + } + + // public static long overhead = 0, underhead = 0, inhead = 0; +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimpleBBModel.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimpleBBModel.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimpleBBModel.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,191 @@ +package gridsim.parallel.BBModel; + +import java.util.Arrays; + +public class SimpleBBModel implements BBModel, BBTaskModel { + private double data, stepComputation; + + private double remainingData, remainingComputations; + + private int remainingComms; + + private int steps, currentStep; + + private State state; + + private int checkpointFrequency = 0; + + private boolean isCheckpoint = false; + + private double checkpointComputations, checkpointCommData; + + private BBTaskModel[] tasksModel; + + // Cache data + private double totalLength; + + public SimpleBBModel(double gridletLength, int gridletCommunications, + double gridletCommData, int tasks) { + this.data = gridletCommData; + this.stepComputation = gridletLength / (gridletCommunications + 1); + steps = 2 * gridletCommunications + 1; + currentStep = 0; + this.totalLength = tasks * gridletLength; + + state = State.COMPUTATION; + + tasksModel = new BBTaskModel[tasks]; + Arrays.fill(tasksModel, this); + // TODO Auto-generated constructor stub + + remainingComputations = gridletLength - stepComputation; + remainingData = gridletCommData * gridletCommunications; + remainingComms = gridletCommunications; + } + + public SimpleBBModel(double gridletLength, int gridletCommunications, + double gridletCommData, int tasks, int commsBetweenCheckpoints, + double checkpointComputations, double checkpointCommData) { + int chekcpoints = (gridletCommunications - 1) / commsBetweenCheckpoints; + this.data = gridletCommData; + this.stepComputation = gridletLength / (gridletCommunications + 1); + steps = 2 * (gridletCommunications + chekcpoints) + 1; + currentStep = 0; + double extraComputations = checkpointComputations * chekcpoints; + this.totalLength = tasks * (gridletLength + extraComputations); + + state = State.COMPUTATION; + + tasksModel = new BBTaskModel[tasks]; + Arrays.fill(tasksModel, this); + // TODO Auto-generated constructor stub + + remainingComputations = gridletLength + extraComputations + - stepComputation; + remainingData = gridletCommData * gridletCommunications + + checkpointCommData * chekcpoints; + remainingComms = gridletCommunications + chekcpoints; + + this.checkpointFrequency = commsBetweenCheckpoints + 1; + this.checkpointCommData = checkpointCommData; + this.checkpointComputations = checkpointComputations; + } + + public boolean nextState() { + // TODO to make sure this implementation, uncoment the next line + // if (currentStep < steps) + currentStep++; + if (currentStep < steps) { + if (checkpointFrequency != 0) + isCheckpoint = ((currentStep / 2 + 1) % checkpointFrequency == 0) + & (currentStep + 1 < steps); + if (currentStep % 2 == 0) { + state = State.COMPUTATION; + remainingComputations -= isCheckpoint ? checkpointComputations + : stepComputation; + } else { + state = State.COMMUNICATION; + remainingData -= isCheckpoint ? checkpointCommData : data; + remainingComms--; + // TODO Fix round errors -> need to be 0; + } + return true; + } else { + state = State.FINISHED; + return false; + } + } + + public double getComputation() { + if (state == State.COMPUTATION) + return isCheckpoint ? checkpointComputations : stepComputation; + else + return 0; + } + + public double getCommunication() { + if (state == State.COMMUNICATION) + return isCheckpoint ? checkpointCommData : data; + else + return 0; + } + + public State getState() { + return state; + } + + public double getRemainingComputations() { + return remainingComputations; + } + + public double getRemainingData() { + // TODO Auto-generated method stub + return remainingData; + } + + public int getRemainingCommunications() { + // TODO Auto-generated method stub + return remainingComms; + } + + public void reset() { + // TODO Auto-generated method stub + currentStep = 0; + remainingComms = steps / 2; + remainingComputations = stepComputation * remainingComms; + remainingData = data * remainingComms; + state = State.COMPUTATION; + } + + public BBTaskModel[] getTaskModel() { + // TODO Auto-generated method stub + return tasksModel; + } + + public double getTotalLength() { + // TODO Auto-generated method stub + return totalLength; + } + + public boolean isCheckpoint() { + return isCheckpoint; + } + + public void backToLastCheckpoint() { + // TODO Auto-generated method stub + if (state == State.FINISHED) { + System.err + .println("Is not posible came back to a checkpoint to a finished gridlet"); + return; + } + if (checkpointFrequency != 0) { + if (currentStep < (checkpointFrequency * 2)) { + isCheckpoint = false; + currentStep = 0; + } else { + currentStep -= currentStep % (checkpointFrequency * 2) + 2; + isCheckpoint = true; + state=(currentStep % 2 == 0)?State.COMPUTATION:State.COMMUNICATION; + } + setResetedCheckpointingCacheData(); + } else { + currentStep = 0; + reset(); + } + + } + + private void setResetedCheckpointingCacheData() { + remainingComms = (steps - currentStep) / 2; + int remainingCheckPoints = (steps / 2) / checkpointFrequency + - (currentStep / 2) / checkpointFrequency; + remainingComputations = stepComputation + * (remainingComms - remainingCheckPoints + (isCheckpoint ? 1 + : 0)) + (remainingCheckPoints - (isCheckpoint ? 1 : 0)) + * checkpointComputations; + + remainingData = data * (remainingComms - remainingCheckPoints) + + remainingCheckPoints * checkpointCommData; + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimplifyResBBParallelGridlet.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimplifyResBBParallelGridlet.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/BBModel/SimplifyResBBParallelGridlet.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,72 @@ +package gridsim.parallel.BBModel; + + +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ResParallelGridlet; + +public class SimplifyResBBParallelGridlet extends ResParallelGridlet { + + private double remainingTotalSimplifyTime = -1; + +// private double remainCommTime = -1.0; + + private BBModel model; + + public SimplifyResBBParallelGridlet(BBParallelGridlet pgridlet, + ResBBParallelTask[] resTasks, InternalNetworkModel internalNet, + BBModel model) { + super(pgridlet, resTasks, internalNet); + this.model = model; + // FIXME <-this is only to test algorithms + } + + // Checkpointing is not considered in this model. + public double updateGridletSimulationAdvance(double localLoad, double timeSpan) { + if (localLoad != 0) + System.err.println("Local load ignored in simplified model"); + if (remainingTotalSimplifyTime < -0.1) + remainingTotalSimplifyTime = initForecastFinishTime(); + if (timeSpan > remainingTotalSimplifyTime) { + timeSpan -= remainingTotalSimplifyTime; + remainingTotalSimplifyTime = 0; + while (model.nextState()) + ; + return timeSpan; + } else { + remainingTotalSimplifyTime -= timeSpan; + return 0; + } + } + + // FIXME �Is really necesary?(To move not, but for a pause gridlet can be? + public void resetComm() { + System.err.println("Comm reset ignored in simplified model"); + } + + // FIXME take care of different statistics times + @Override + public void backToLastCheckpoint() { + System.err.println("checkpointing ignored in simplified model"); + } + + /** + * Gets a forecast finish time of the task. + * + * @return estimated Tasks's finish time. + */ + public double getForecastFinishTime() { + return remainingTotalSimplifyTime; + } + private double initForecastFinishTime(){ + double commTime = internalNet.getAssociatedCommunicationTime(model + .getRemainingData(), model.getRemainingCommunications(), + getNumPE()); + return super.getForecastFinishTime() + commTime; + } + + @Override + protected boolean isFinished() { + return this.model.getState().equals(BBModel.State.FINISHED); + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingAlloc.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingAlloc.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingAlloc.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,203 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: BackFillingAlloc.java,v 1.2 2007/11/14 09:56:10 julio Exp $ + */ + +package gridsim.parallel.allocs; + +import java.util.Comparator; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.Map.Entry; + +import gridsim.GridSim; +import gridsim.Gridlet; +import gridsim.Machine; +import gridsim.PE; +import gridsim.PEList; +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ParallelAllocPolicy; +import gridsim.parallel.ResParallelGridlet; + +/** + * + * @author Julio Lopez + * @invariant $none + */ +public class BackFillingAlloc extends ParallelAllocPolicy { + protected Set<ResParallelGridlet> sorteExecList; + + protected boolean onlyExecutionFilling; + + public BackFillingAlloc(String resourceName, String entityName, + InternalNetworkModel internalNet, boolean onlyExecutionFilling) + throws Exception { + super(resourceName, entityName, internalNet); + sorteExecList = new TreeSet<ResParallelGridlet>( + new Comparator<ResParallelGridlet>() { + public int compare(ResParallelGridlet o1, + ResParallelGridlet o2) { + if(o1.equals(o2)) return 0; + double estTime=((o1.getEstimatedTime() + o1 + .getExecStartTime()) - (o2.getEstimatedTime() + o2 + .getExecStartTime())); + //It's necessary give a order to + return (estTime>0)?1:-1; + //return (int) + } + }); + this.onlyExecutionFilling = onlyExecutionFilling; + + } + + + + /** + * Allocates the first Gridlet in the Queue list (if any) to execution list + * + * @pre $none + * @post $none + */ + protected void allocateQueueGridlet() { + // if there are many Gridlets in the QUEUE, then allocate a + // PE to the first Gridlet in the list since it follows FCFS + // (First Come First Serve) approach. Then removes the Gridlet from + // the Queue list + + // FIXME improve performance + + if (sGridletQueueList.size() > 0 + && sGridletInExecList.size() < super.totalPE_) { + ResParallelGridlet rgl; + + int free = super.resource_.getNumFreePE(); + + rgl = sGridletQueueList.peek(); + + while (rgl.getNumPE() <= free) { + // allocate the Gridlet into an empty PE slot and remove it + // from + // the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.poll(); + // sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + rgl = sGridletQueueList.peek(); + if (rgl == null) + return; + } + // This check is duplicated, but this is not 100% sure and is not + // computational expensive + if (free > 0) + backfillingLN(); + // else System.err.println("Avoid backfilling"); + + } + } + + protected void backfillingLN() { + + // FIXME improve performance + int free = super.resource_.getNumFreePE(); + if (!(free > 0 & sGridletQueueList.size() > 0)) + return; + + int futureFree = free; + TreeMap<Double, Integer> timePE = new TreeMap<Double, Integer>(); + timePE.put(0d, free); + sorteExecList.clear(); + sorteExecList.addAll(sGridletInExecList); + Iterator<ResParallelGridlet> sIt = sorteExecList.iterator(); + ResParallelGridlet rgl; + double time; + while (sIt.hasNext()) { + rgl = sIt.next(); + futureFree += rgl.getNumPE(); + time = (rgl.getExecStartTime() + rgl.getEstimatedTime()) + - GridSim.clock() + 1; + timePE.put(time, futureFree); + } + if(futureFree!=totalPE_) + System.err.println("Mala iniciacion"); + Iterator<ResParallelGridlet> it = sGridletQueueList.iterator(); + while (it.hasNext() && free > 0) { + rgl = it.next(); + // if(rgl.getNumPE()>free & onlyExecutionFilling) continue; + double starTime = -1d, endTime = -1; + boolean validating = false; + for (Entry<Double, Integer> mark : timePE.entrySet()) { + if (validating) { + if (((!onlyExecutionFilling) | (starTime == 0d)) + & (mark.getKey() >= endTime)) { + // if(!onlyExecutionFilling) break; + break; + // if(!(onlyExecutionFilling&&(starTime != 0d))) break; + // else System.err.println("Special rejection"); + } else if (mark.getValue() < rgl.getNumPE()) { + validating = false; + endTime = -1; + // break; + } + } else { + if (mark.getValue() >= rgl.getNumPE()) { + validating = true; + starTime = mark.getKey(); + endTime = starTime + rgl.getEstimatedTime(); + } + } + } + if (validating) { + for (Entry<Double, Integer> mark : timePE.subMap(starTime, + endTime).entrySet()) { + futureFree = mark.getValue(); + mark.setValue(futureFree - rgl.getNumPE()); + } + if (!timePE.containsKey(endTime)) + timePE.put(endTime, futureFree); + if (starTime == 0d) { + if (rgl.getNumPE() > free) { + System.err + .println("Backfilling called before check completation. Gridlet " + + rgl.getGridletID() + " bad allocated"); + continue; + } + // allocate the Gridlet into an empty PE slot and + // remove it from the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + } + } else { + // if(!onlyExecutionFilling) + System.err.println("Never would be reached this point"); + /* + * else System.err.println("Rejected candidate"); + */ + } + } + + } + + + @Override + public String getPolicyName() { + if (onlyExecutionFilling) + return "ConservativeBackFillingExecution"; + else + return "ConservativeBackFillingPredictive"; + } + + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingL1Alloc.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingL1Alloc.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/BackFillingL1Alloc.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,161 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: BackFillingL1Alloc.java,v 1.2 2007/11/14 09:56:10 julio Exp $ + */ + +package gridsim.parallel.allocs; + +import java.util.Comparator; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import gridsim.GridSim; +import gridsim.Gridlet; +import gridsim.Machine; +import gridsim.PE; +import gridsim.PEList; +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ParallelAllocPolicy; +import gridsim.parallel.ResParallelGridlet; + +/** + * SpaceParallelShared class is an allocation policy for GridResource that + * behaves exactly like First Come First Serve (FCFS). This is a modification to + * SpaceShared that allows each Gridlet to be executed in more than one + * Processing Element (PE). Versioned to add support to parallel gridlets. + * + * @author Julio Lopez, based on SpaceShared by Manzur Murshed and Rajkumar + * Buyya + * @since GridSim Toolkit 4.0 + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.SpaceShare + * @invariant $none + */ +public class BackFillingL1Alloc extends ParallelAllocPolicy { + private SortedSet<ResParallelGridlet> sorteExecList; + + public BackFillingL1Alloc(String resourceName, String entityName, + InternalNetworkModel internalNet) throws Exception { + super(resourceName, entityName, internalNet); + sorteExecList = new TreeSet<ResParallelGridlet>( + new Comparator<ResParallelGridlet>() { + public int compare(ResParallelGridlet o1, + ResParallelGridlet o2) { + if(o1.equals(o2)) return 0; + double estTime=((o1.getEstimatedTime() + o1 + .getExecStartTime()) - (o2.getEstimatedTime() + o2 + .getExecStartTime())); + return (estTime>0)?1:-1; + } + }); + + } + + + /** + * Allocates the first Gridlet in the Queue list (if any) to execution list + * + * @pre $none + * @post $none + */ + protected void allocateQueueGridlet() { + // if there are many Gridlets in the QUEUE, then allocate a + // PE to the first Gridlet in the list since it follows FCFS + // (First Come First Serve) approach. Then removes the Gridlet from + // the Queue list + + // FIXME improve performance + + if (sGridletQueueList.size() > 0 + && sGridletInExecList.size() < super.totalPE_) { + ResParallelGridlet rgl; + + int free = super.resource_.getNumFreePE(); + + rgl = sGridletQueueList.peek(); + + while (rgl.getNumPE() <= free) { + // allocate the Gridlet into an empty PE slot and remove it + // from + // the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.poll(); + // sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + rgl = sGridletQueueList.peek(); + if (rgl == null) + return; + } + if (free > 0) + backfillingL1(); + } + } + + protected void backfillingL1() { + int free = super.resource_.getNumFreePE(); + if (!(free > 0 & sGridletQueueList.size() > 0)) + return; + ResParallelGridlet rgl; + rgl = sGridletQueueList.peek(); + double extraTime = rgl.getEstimatedTime(); + // BACKFILLING code + sorteExecList.clear(); + sorteExecList.addAll(sGridletInExecList); + Iterator<ResParallelGridlet> sIt = sorteExecList.iterator(); + int extraPE = free - rgl.getNumPE(); + while (extraPE < 0 && sIt.hasNext()) { + rgl = sIt.next(); + extraPE += rgl.getNumPE(); + } + double maxTime = rgl.getExecStartTime() + rgl.getEstimatedTime() + - GridSim.clock(); + Iterator<ResParallelGridlet> it = sGridletQueueList.iterator(); + while (it.hasNext() && free > 0) { + rgl = it.next(); + if (rgl.getNumPE() <= free) + if (rgl.getEstimatedTime() < maxTime) { + // allocate the Gridlet into an empty PE slot and + // remove it from the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + } else if (rgl.getEstimatedTime() < maxTime + extraTime + && rgl.getNumPE() <= extraPE) { + // allocate the Gridlet into an empty PE slot and + // remove it from the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + extraPE -= rgl.getNumPE(); + //System.err.println("Extra bacfilled with gridlet "+ rgl.getGridletID()); + } /*else { + // System.err.println("Not bacfilled with gridlet + // "+rgl.getGridletID()); + }*/ + // FIXME this solution is correct, but the performance can + // decrease. + } + + } + + @Override + public String getPolicyName() { + return "ConservativeBackFillingL1"; + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/EASYBackFillingAlloc.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/EASYBackFillingAlloc.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/EASYBackFillingAlloc.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,167 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: EASYBackFillingAlloc.java,v 1.2 2007/11/14 09:56:10 julio Exp $ + */ + +package gridsim.parallel.allocs; + +import java.util.Comparator; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import gridsim.GridSim; +import gridsim.Gridlet; +import gridsim.Machine; +import gridsim.PE; +import gridsim.PEList; +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ParallelAllocPolicy; +import gridsim.parallel.ResParallelGridlet; + +/** + * SpaceParallelShared class is an allocation policy for GridResource that + * behaves exactly like First Come First Serve (FCFS). This is a modification to + * SpaceShared that allows each Gridlet to be executed in more than one + * Processing Element (PE). Versioned to add support to parallel gridlets. + * + * @author Julio Lopez, based on SpaceShared by Manzur Murshed and Rajkumar + * Buyya + * @since GridSim Toolkit 4.0 + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.SpaceShare + * @invariant $none + */ +public class EASYBackFillingAlloc extends ParallelAllocPolicy { + private SortedSet<ResParallelGridlet> sorteExecList; + + public EASYBackFillingAlloc(String resourceName, String entityName, + InternalNetworkModel internalNet) throws Exception { + super(resourceName, entityName, internalNet); + sorteExecList = new TreeSet<ResParallelGridlet>( + new Comparator<ResParallelGridlet>() { + public int compare(ResParallelGridlet o1, + ResParallelGridlet o2) { + if(o1.equals(o2)) return 0; + double estTime=((o1.getEstimatedTime() + o1 + .getExecStartTime()) - (o2.getEstimatedTime() + o2 + .getExecStartTime())); + return (estTime>0)?1:-1; + } + }); + + } + + + + /** + * Allocates the first Gridlet in the Queue list (if any) to execution list + * + * @pre $none + * @post $none + */ + protected void allocateQueueGridlet() { + // if there are many Gridlets in the QUEUE, then allocate a + // PE to the first Gridlet in the list since it follows FCFS + // (First Come First Serve) approach. Then removes the Gridlet from + // the Queue list + + // FIXME improve performance + + if (sGridletQueueList.size() > 0 + && sGridletInExecList.size() < super.totalPE_) { + ResParallelGridlet rgl; + + int free = super.resource_.getNumFreePE(); + + rgl = sGridletQueueList.peek(); + + while (rgl.getNumPE() <= free) { + // allocate the Gridlet into an empty PE slot and remove it + // from + // the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.poll(); + // sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + rgl = sGridletQueueList.peek(); + if (rgl == null) + return; + } + if (free > 0) + easyBackfilling(); + // double extraTime = rgl.getEstimatedTime(); + // BACKFILLING code + // FIXME this solution is correct, but the performance can + // decrease. + + } + + } + + private void easyBackfilling() { + int free = super.resource_.getNumFreePE(); + if (!(free > 0 & sGridletQueueList.size() > 0)) + return; + ResParallelGridlet rgl; + rgl = sGridletQueueList.peek(); + // TODO Auto-generated method stub + sorteExecList.clear(); + sorteExecList.addAll(sGridletInExecList); + Iterator<ResParallelGridlet> sIt = sorteExecList.iterator(); + int extraPE = free - rgl.getNumPE(); + while (extraPE < 0 && sIt.hasNext()) { + rgl = sIt.next(); + extraPE += rgl.getNumPE(); + } + double maxTime = rgl.getExecStartTime() + rgl.getEstimatedTime() + - GridSim.clock(); + Iterator<ResParallelGridlet> it = sGridletQueueList.iterator(); + while (it.hasNext() && free > 0) { + rgl = it.next(); + if (rgl.getNumPE() <= free) + if (rgl.getEstimatedTime() < maxTime) { + // allocate the Gridlet into an empty PE slot and + // remove it from the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + } else if (rgl.getNumPE() <= extraPE) { + // allocate the Gridlet into an empty PE slot and + // remove it from the queue list + boolean success = allocatePEstoGridlet(rgl); + if (success == true) { + sGridletQueueList.remove(rgl); + } + // FIXME Update with another threads, is it better + free -= rgl.getNumPE(); + extraPE -= rgl.getNumPE(); + // System.err.println("Extra bacfilled with gridlet + // "+rgl.getGridletID()); + } /*else { + // System.err.println("Not bacfilled with gridlet + // "+rgl.getGridletID()); + }*/ + } + + } + + + + @Override + public String getPolicyName() { + return "EASYBackFilling"; + } + +} Added: branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/FIFOAlloc.java =================================================================== --- branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/FIFOAlloc.java (rev 0) +++ branches/gridsim-4.1-parallel/source/gridsim/parallel/allocs/FIFOAlloc.java 2008-03-28 11:14:42 UTC (rev 164) @@ -0,0 +1,155 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * $Id: FIFOAlloc.java,v 1.2 2007/11/14 09:56:10 julio Exp $ + */ + +package gridsim.parallel.allocs; + +import java.util.Iterator; + +import gridsim.Gridlet; +import gridsim.Machine; +import gridsim.PE; +import gridsim.PEList; +import gridsim.parallel.InternalNetworkModel; +import gridsim.parallel.ParallelAllocPolicy; +import gridsim.parallel.ResParallelGridlet; + +/** + * SpaceParallelShared class is an allocation policy for GridResource that + * behaves exactly like First Come First Serve (FCFS). This is a modification to + * SpaceShared that allows each Gridlet to be executed in more than one + * Processing Element (PE). Versioned to add support to parallel gridlets. + * + * @author Julio Lopez, based on SpaceShared by Manzur Murshed and Rajkumar + * Buyya + * @since GridSim Toolkit 4.0 + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.SpaceShare + * @invariant $none + */ +public class FIFOAlloc extends ParallelAllocPolicy { + + public FIFOAlloc(String resourceName, String entityName, + InternalNetworkModel internalNet) throws Exception { + super(resourceName, entityName, internalNet); + } + + /** + * Allocates a Gridlet into a free PE and sets the Gridlet status into + * INEXEC and PE status into busy afterwards + * + * @param rgl + * a ResGridlet object + * @return <tt>true</tt> if there is an empty PE to process this Gridlet, + * <tt>false</tt> otherwise + * @pre rgl != null + * @post $none + */ +/* protected boolean allocatePEstoGridlet(ResParallelGridlet rpgl) { + // FIXME First basic implementation + // ResParallelGridlet rpgl = (ResParallelGridlet) rgl; + int tasks = rpgl.getNumPE(); + + int i = 0; + while (i < tasks) { + + // IDENTIFY MACHINE which has a free PE and add this Gridlet to it. + Machine myMachine = resource_.getMachineWithFreePE(); + + // If a Machine is empty then ignore the rest + if (myMachine == null) { + System.out.println("Fallou"); + return false; + // FIXME Esta salida no es valida + } + + // gets the list of PEs and find one empty PE + PEList MyPEList = myMachine.getPEList(); + while (MyPEList.getNumFreePE() > 0 && (i < tasks)) { + int freePEID = MyPEList.getFreePEID(); + rpgl.setMachineAndPEID(myMachine.getMachineID(), freePEID, + MyPEList.getMIPSRating(freePEID)); + i++; + // Set allocated PE to BUSY status + super.resource_.setStatusPE(PE.BUSY, myMachine.getMachineID(), + freePEID); + } + + //FIXME Task could be not finished + // FIXME No sense set to a rgl, only fot a task + // rgl.setMachineAndPEID(myMachine.getMachineID(), freePE); + + } + + // ALLOCATE IMMEDIATELY + rpgl.setGridletStatus(Gridlet.INEXEC); // change Gridlet status + // add this Gridlet into execution list + sGridletInExecList.add(rpgl); + + // Identify Completion Time and Set Interrupt + // int rating = machineRating_[ rgl.getMachineID() ]; + double time = rpgl.getForecastFinishTime(); + // forecastFinishTime( rating , rgl.getRemainingGridletLength() ); + + double roundUpTime = Math.ceil(time); // rounding up + rpgl.setFinishTime(roundUpTime); + + // then send this into itself + super.sendInternalEvent(roundUpTime); + return true; + }*/ + + /** + * Allocates the first Gridlet in the Queue list (if any) to execution list + * + * @pre $none + * @post $none + */ + protected void allocateQueueGridlet() { + // if there are many Gridlets in the QUEUE, then allocate a + // PE to the first Gridlet in the list since it follows FCFS + // (First Come First Serve) approach. Then removes the Gridlet from + // the Queue list + if (sGridletQueueList.size() > 0 + && sGridletInExecList.size() < super.totalPE_) { + ResParallelGridlet rgl; + + Iterator<ResParallelGridlet> it = sGridletQueueList.iterator(); + int free =... [truncated message content] |
From: <mar...@us...> - 2008-03-21 23:28:34
|
Revision: 163 http://gridsim.svn.sourceforge.net/gridsim/?rev=163&view=rev Author: marcos_dias Date: 2008-03-21 16:10:38 -0700 (Fri, 21 Mar 2008) Log Message: ----------- This update fixes a bug in the advance reservation policies. Immediate reservations could be refused if the start time was slightly smaller than current time. If the start time of an advance reservation is smaller than the current time, then the start time will be changed to current simulation time. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-19 08:30:54 UTC (rev 162) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-21 23:10:38 UTC (rev 163) @@ -302,7 +302,7 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); - if(startTime == 0) + if(startTime == 0 || startTime < currentTime) startTime = currentTime; // creates a Server Side Reservation (i.e. SSReservation) @@ -356,9 +356,16 @@ " PEs from " + startTime + " to " + (startTime + duration)); System.out.println("--> The resource could not handle the reservation."); + // Gets availability information and provides it as options + AvailabilityInfo availability = super.allowBorrowing_ ? + getAvailabilityInfo(startTime, Integer.MAX_VALUE) : + getAvailabilityInfo(sRes.getPartitionID(), + startTime, Integer.MAX_VALUE); + reservation.setStatus(Reservation.STATUS_FAILED); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - sendARMessage(response); + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + sendARMessage(response); return; } @@ -700,7 +707,8 @@ * entries that correspond to the availability profile between the times * specified by the requester. */ - protected AvailabilityInfo getAvailabilityInfo(double startTime, int duration) { + protected AvailabilityInfo getAvailabilityInfo(double startTime, + int duration) { AvailabilityInfo list = new AvailabilityInfo(); int anchorIndex = -1; @@ -1012,9 +1020,10 @@ // updates the availability profile accordingly profile_.allocateImmediateRanges(queueId, startTime + duration, selected); + return true; } // Tries all the queues - else { + else if (super.allowBorrowing_) { // gets all available PEs during given time interval PERangeList overallAvailPEs = @@ -1030,22 +1039,19 @@ // additional PEs required int addRequired = reqPE - ranges.getNumPE(); - if(addRanges != null && addRanges.getNumPE() >= addRequired) { - // borrows the additional PEs required from the partitions - // and adds them into the specified queue - addRanges = super.selectPERangeList(addRequired, addRanges); - profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); + // borrows the additional PEs required from the partitions + // and adds them into the specified queue + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); - // allocates the ranges to the gridlet - ranges.addAll(addRanges); - profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); - res.setPERangeList(ranges); - } - else { - return false; - } + // allocates the ranges to the gridlet + ranges.addAll(addRanges); + profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); + res.setPERangeList(ranges); + return true; } - return true; + + return false; } /* @@ -1089,8 +1095,10 @@ // allocates the ranges and updates the availability profile profile_.allocatePERanges(queueId, anchorIndex, tailIndex, selected, startTime, res.getActualFinishTime()); + + return true; } - else { + else if (super.allowBorrowing_) { // number of additional PEs required int addRequired = reqPE - ranges.getNumPE(); @@ -1131,9 +1139,11 @@ ranges, startTime, startTime + duration); res.setPERangeList(ranges); + + return true; } - return true; + return false; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-19 08:30:54 UTC (rev 162) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-21 23:10:38 UTC (rev 163) @@ -306,7 +306,7 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); - if(startTime == 0) + if(startTime == 0 || startTime < currentTime) startTime = currentTime; // creates a Server Side Reservation (i.e. SSReservation) @@ -360,9 +360,16 @@ " PEs from " + startTime + " to " + (startTime + duration)); System.out.println("--> The resource could not handle the reservation."); + // Gets availability information and provides it as options + AvailabilityInfo availability = super.allowBorrowing_ ? + getAvailabilityInfo(startTime, Integer.MAX_VALUE) : + getAvailabilityInfo(sRes.getPartitionID(), + startTime, Integer.MAX_VALUE); + reservation.setStatus(Reservation.STATUS_FAILED); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - sendARMessage(response); + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + sendARMessage(response); return; } @@ -1019,9 +1026,11 @@ // updates the availability profile accordingly profile_.allocateImmediateRanges(queueId, startTime + duration, selected); + + return true; } // Tries all the queues - else { + else if (super.allowBorrowing_) { // gets all available PEs during given time interval PERangeList overallAvailPEs = @@ -1037,22 +1046,20 @@ // additional PEs required int addRequired = reqPE - ranges.getNumPE(); - if(addRanges != null && addRanges.getNumPE() >= addRequired) { - // borrows the additional PEs required from the partitions - // and adds them into the specified queue - addRanges = super.selectPERangeList(addRequired, addRanges); - profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); + // borrows the additional PEs required from the partitions + // and adds them into the specified queue + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); - // allocates the ranges to the gridlet - ranges.addAll(addRanges); - profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); - res.setPERangeList(ranges); - } - else { - return false; - } + // allocates the ranges to the gridlet + ranges.addAll(addRanges); + profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); + res.setPERangeList(ranges); + + return true; } - return true; + + return false; } /* @@ -1096,8 +1103,10 @@ // allocates the ranges and updates the availability profile profile_.allocatePERanges(queueId, anchorIndex, tailIndex, selected, startTime, res.getActualFinishTime()); + + return true; } - else { + else if(super.allowBorrowing_) { // number of additional PEs required int addRequired = reqPE - ranges.getNumPE(); @@ -1138,9 +1147,11 @@ ranges, startTime, startTime + duration); res.setPERangeList(ranges); + + return true; } - return true; + return false; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-19 08:30:54 UTC (rev 162) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-21 23:10:38 UTC (rev 163) @@ -239,7 +239,7 @@ boolean success = true; // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + if(startTime == 0 || startTime <= currentTime) { // sets the start time of the reservation as the current time startTime = currentTime; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2008-03-19 08:30:52
|
Revision: 162 http://gridsim.svn.sourceforge.net/gridsim/?rev=162&view=rev Author: sulistio Date: 2008-03-19 01:30:54 -0700 (Wed, 19 Mar 2008) Log Message: ----------- remove this class since it is not used any more. Instead FlowInput and FlowOutput will take over the functionalities of this class. Removed Paths: ------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java Deleted: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java 2008-03-18 00:40:38 UTC (rev 161) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowBuffer.java 2008-03-19 08:30:54 UTC (rev 162) @@ -1,954 +0,0 @@ -/* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * Author: James Broberg & Anthony Sulistio (Adapted from original Input.java & Output.java) - */ - -package gridsim.net.flow; - -import gridsim.*; -import gridsim.net.*; -import gridsim.util.*; - -import eduni.simjava.*; - -import java.util.*; - - -/** - * GridSim FlowBuffer defines a port through which a simulation entity sends - * and receives data to the simulated network using flow networking principles. - * <p> - * It maintains an event queue to serialize - * the data-out-flow and data-in-flow and delivers to the destination entity. - * - * @author James Broberg - * @since GridSim Toolkit 4.0 - * @invariant $none - */ -public class FlowBuffer extends Sim_entity implements NetIO -{ - private Sim_port outPort_; // output port - private Link link_; // a link to this output entity - private double baudRate_; // baud rate of this entity - private final int SIZE = 8; // 1 byte in bits - private static int pktID_ = 0; // packet ID counter - private Vector outPacketList_; // store a list of packets - private HashMap<Integer, Packet> activeFlows_; // stores a list of active Flows - private Random random_; // selects to which junk packets go to - private TrafficGenerator gen_; // background traffic generator - private ArrayList list_; // list of resources + user entities - private boolean hasStarted_; // a flag for background traffic has started - private static final int BITS = 8; // 1 byte = 8 bits - - - /** - * Allocates a new FlowBuffer object - * @param name the name of this object - * @param baudRate the communication speed - * @throws NullPointerException This happens when creating this entity - * before initializing GridSim package or this entity name - * is <tt>null</tt> or empty - * @pre name != null - * @pre baudRate >= 0.0 - * @post $none - */ - public FlowBuffer(String name, double baudRate) throws NullPointerException - { - super(name); - this.baudRate_ = baudRate; - link_ = null; - outPacketList_ = null; - activeFlows_ = null; - //pktID_ = 0; - - outPort_ = new Sim_port("output_buffer"); - super.add_port(outPort_); - - // for sending background traffic - gen_ = null; - list_ = null; - random_ = null; - hasStarted_ = false; - - System.out.println("Initialising FlowBuffer id " + super.get_id() + " name " + super.get_name()); - } - - /** - * Sets the background traffic generator for this entity. - * <p> - * When simulation starts, this entity will automatically sends junk - * packets to resource entities. - * @param gen a background traffic generator - * @return <tt>true</tt> if successful, <tt>false</tt> otherwise - * @pre gen != null - * @post $none - */ - - // TODO: Background traffic not yet implemented, do not use! - public boolean setBackgroundTraffic(TrafficGenerator gen) - { - if (gen == null) { - return false; - } - - gen_ = gen; - if (list_ == null) { - list_ = new ArrayList(); - } - - return true; - } - - /** - * Sets the background traffic generator for this entity. - * <p> - * When simulation starts, this entity will automatically sends junk - * packets to resource entities and other entities. <br> - * NOTE: Sending background traffic to itself is not supported. - * - * @param gen a background traffic generator - * @param userName a collection of user entity name (in String object). - * @return <tt>true</tt> if successful, <tt>false</tt> otherwise - * @pre gen != null - * @pre userName != null - * @post $none - */ - - // TODO: Background traffic not yet implemented, do not use! - public boolean setBackgroundTraffic(TrafficGenerator gen, - Collection userName) - { - if (gen == null || userName == null) { - return false; - } - - boolean flag = true; - try - { - gen_ = gen; - if (list_ == null) { - list_ = new ArrayList(); - } - - // iterates through each list to check whether it is a valid - // entity name or not - Iterator it = userName.iterator(); - int id = -1; - while( it.hasNext() ) - { - String name = (String) it.next(); - - // check whether it is sending to itself - id = GridSim.getEntityId("Output_" + name); - if (id == super.get_id()) - { - System.out.println(super.get_name() + - ".setBackgroundTraffic(): Warning - can not send " + - "junk packets to itself."); - continue; - } - - // get the ID of other entity - id = GridSim.getEntityId(name); - if (id > 0) - { - Integer obj = new Integer(id); - list_.add(obj); - } - // ignore for invalid entity - else - { - System.out.println(super.get_name() + - ".setBackgroundTraffic(): Warning - invalid entity " + - "name for \"" + name + "\"."); - } - } - } - catch(Exception e) { - flag = false; - } - - return flag; - } - - /** - * Sets this entity's link. This should be used only if the network - * extensions are being used. - * - * @param link the link to which this FlowBuffer entity should send data - * @pre link != null - * @post $none - */ - public void addLink(Link link) - { - this.link_ = link; - baudRate_ = link_.getBaudRate(); - outPacketList_ = new Vector(); - activeFlows_ = new HashMap(); - } - - /** - * Gets the baud rate - * @return the baud rate - * @deprecated As of GridSim 2.1, replaced by {@link #getBaudRate()} - * @pre $none - * @post $result >= 0.0 - */ - public double GetBaudRate() { - return this.getBaudRate(); - } - - /** - * Gets the baud rate - * @return the baud rate - * @pre $none - * @post $result >= 0.0 - */ - public double getBaudRate() { - return baudRate_; - } - - /** - * Gets the I/O real number based on a given value - * @param value the specified value - * @return real number - * @deprecated As of GridSim 2.1, replaced by {@link #realIO(double)} - * @pre $none - * @post $result >= 0.0 - */ - public double real_io(double value) { - return this.realIO(value); - } - - /** - * Gets the I/O real number based on a given value - * @param value the specified value - * @return real number - * @pre $none - * @post $result >= 0.0 - */ - public double realIO(double value) { - return GridSimRandom.realIO(value); - } - - /** - * A method that gets one process event at one time until the end - * of a simulation, then delivers an event to the entity (its parent) - * @pre $none - * @post $none - */ - public void body() - { - - // find out ids for entities that are not part of simulation network - // topology, such as GIS, GridSimShutdown and GridStatistics - int gisID = GridSim.getGridInfoServiceEntityId(); - int statID = GridSim.getGridStatisticsEntityId(); - int shutdownID = GridSim.getGridSimShutdownEntityId(); - - // start generating some junk packets or background traffic - // startBackgroundTraffic(); - - // Process incoming events - while ( Sim_system.running() ) - { - Sim_event ev = new Sim_event(); - super.sim_get_next(ev); // get the next event in the queue - - // if the simulation finishes then exit the loop - if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { - break; - } - - System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); - - // handle different types of incoming events - switch ( ev.get_tag() ) - { - case GridSimTags.SEND_PACKET: - System.out.println(super.get_name() + ".body(): sendPacket() + at time = " + GridSim.clock()); - sendPacket(); - break; - - // submit ping() request - case GridSimTags.INFOPKT_SUBMIT: - System.out.println(super.get_name() + ".body(): sendInfoPacket() + at time = " + GridSim.clock()); - sendInfoPacket(ev); - break; - - // replying ping() request from another entity - case GridSimTags.INFOPKT_RETURN: - System.out.println(super.get_name() + ".body(): returnInfoPacket() + at time = " + GridSim.clock()); - returnInfoPacket(ev); - break; - - // activate background traffic - case GridSimTags.JUNK_PKT: - generateBackgroundTraffic(); - break; - - case GridSimTags.PKT_FORWARD: - System.out.println(super.get_name() + ".body(): getDataFromLink() + at time = " + GridSim.clock()); - getDataFromLink(ev); - break; - - // Check if initial flow duration estimation was accurate - case GridSimTags.FLOW_HOLD: - System.out.println(super.get_name() + ".body(): checkForecast() + at time = " + GridSim.clock()); - checkForecast(ev); - break; - - // Update flow duration forecase - case GridSimTags.FLOW_UPDATE: - System.out.println(super.get_name() + ".body(): updateForecast() + at time = " + GridSim.clock()); - updateForecast(ev); - break; - - case GridSimTags.FLOW_RETURN: - submitAckToLink(ev); - break; - - default: - defaultSend(ev, gisID, statID, shutdownID); - break; - } - } - - System.out.println(super.get_name() + ":%%%% Exiting body() at time " + - GridSim.clock() ); - } - - /** - * Check the forecast of a flow, and send data to output port if flow still exists - * - * @param ev the flow hold notification event - * @pre ev != null - * @post $none - */ - private synchronized void checkForecast(Sim_event ev) { - int pktID = (Integer) ev.get_data(); // ID of flow to be checked - FlowPacket fp = null; // Reference to flow packet that needs forecast update - FlowPacket fpAck = null; - - System.out.println(super.get_name() + ".checkForecast(): checking pkt id # " + pktID); - - // If flow hasn't already finished, send it to outPort - if ((fp = (FlowPacket) activeFlows_.get(pktID)) != null) { - Object data = fp.getData(); - IO_data io = new IO_data( data, fp.getSize(), - outPort_.get_src()); - super.sim_schedule(outPort_, GridSimTags.SCHEDULE_NOW, fp.getTag() , io.getData()); - activeFlows_.remove(pktID); - - // Send ack to source of flow - System.out.println(super.get_name() + ".checkForecast(): flow came from " + GridSim.getEntityName(fp.getSrcID()) - + " heading to " + GridSim.getEntityName(fp.getDestID())); - int oldDestID = fp.getDestID(); - int oldSrcID = fp.getSrcID(); - - IO_data ackData = new IO_data(fp.getData(), fp.getSize(), oldSrcID - 1); - fpAck = new FlowPacket(ackData,fp.getID(),fp.getSize(),GridSimTags.FLOW_RETURN,super.get_id(), - oldSrcID - 1, fp.getNetServiceType(), 1, 1); - fpAck.setRemSize(0); - fpAck.setStartTime(fp.getStartTime()); - fpAck.setLatency(fp.getLatency()); - - super.sim_schedule(super.get_id(), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_RETURN, fpAck); - - } else { - System.out.println(super.get_name() + ".checkForecast(): pkt id # " + pktID + " already removed"); - - } - - } - - /** - * Update the forecast of a flow, delete the old forecast and schedule a new flow hold - * event in the future with the corrected forecast - * - * @param ev the flow update notification event - * @pre ev != null - * @post $none - */ - private synchronized void updateForecast(Sim_event ev) { - int pktID = (Integer) ev.get_data(); // ID of flow to be updated - FlowPacket fp = null; // Reference to flow packet that needs forecast update - double duration = 0.0; // New forecast duration from current Gridsim.clock() - long remSizeOld = 0; // Previous remaining size - double bandwidthOld = 0.0; // Previous bottleneck BW - int sourceID = ev.get_src(); // ID of source of notification (FlowLink) - int cancelledFlow = 0; // Count of canceled future events that match old forecast - - System.out.println(super.get_name() + ".updateForecast(): updating pkt id # " + pktID); - - // If flow hasn't already finished and been cleared... - if ((fp = (FlowPacket) activeFlows_.get(pktID)) != null) { - remSizeOld = fp.getRemSize(); - bandwidthOld = fp.getBandwidth_(); - System.out.println(super.get_name() + "updateForecast(): rem size is " + remSizeOld + "BW old is " + bandwidthOld); - Iterator it = (fp.getLinks_()).iterator(); - - while (it.hasNext()) { - FlowLink fl = (FlowLink) it.next(); - if (fl.get_id() == sourceID) { - fp.setBandwidth_(fl.getBaudRate()); - fp.setBottleneckID(sourceID); - } - } - - fp.setRemSize((long)(remSizeOld*BITS - (GridSim.clock()-fp.getUpdateTime())*bandwidthOld)); - duration = fp.getRemSize()/fp.getBandwidth_(); - System.out.println(super.get_name() + " new remaining duration add " + duration); - - FilterFlow filter = new FilterFlow(fp.getID(), GridSimTags.FLOW_HOLD); - cancelledFlow = this.sim_cancel(filter, null); - - if (cancelledFlow != 0) { - System.out.println(super.get_name() + ".updateForecast(): old forecast cancelled"); - } - - - super.sim_schedule(super.get_id(), duration, GridSimTags.FLOW_HOLD , new Integer(fp.getID())); - } - } - - /** - * Generates few junk packets at the given interval - * @pre $none - * @post $none - */ - private synchronized void generateBackgroundTraffic() - { - // get the next inter-arrival time for these junk packets - long time = gen_.getNextPacketTime(); - - // get the sending pattern - int pattern = gen_.getPattern(); - - // for initial start-up, get the list of all resources first - if (hasStarted_ == false) - { - // get list of resource IDs from GIS - LinkedList resList = GridSim.getGridResourceList(); - - // if the list is empty then schedule the next time - if (resList == null && list_.size() == 0) - { - super.sim_schedule(super.get_id(), time, GridSimTags.JUNK_PKT); - return; - } - - hasStarted_ = true; - list_.addAll(resList); // add resource IDs into the current list - - // sets the sending pattern - if (pattern == TrafficGenerator.SEND_ONE_ONLY && random_ == null) { - random_ = new Random(); - } - } - - // get the required info for generating this background traffic - long size = gen_.getNextPacketSize(); // packet size - long freq = gen_.getNextPacketFreq(); // packet freq - int type = gen_.getServiceType(); // packet type - int tag = GridSimTags.JUNK_PKT; // packet tag - - // we need to packetsize the data, all packets are sent with size MTU. - // only the last packet contains the data, the receiver should - // throw away all other packets - int MTU = link_.getMTU(); - int numPackets = (int) Math.ceil( size / (MTU * 1.0) ); - - /********* // DEBUG info - System.out.println(); - System.out.println(super.get_name() + - ": START GENERATE BG traffic... at time "+ GridSim.clock()); - System.out.println(super.get_name() + - ": NEXT background traffic will start at " + time); - System.out.println(super.get_name() + - " num PACKETS = " + numPackets + ", freq = " + freq); - *********/ - - int i = 0; - int destId = -1; - - // send to one of the entity using uniform distribution - if (pattern == TrafficGenerator.SEND_ONE_ONLY) - { - int index = random_.nextInt( list_.size() ); - destId = ((Integer) list_.get(index)).intValue(); - - /********* // DEBUG info - System.out.println(super.get_name() + ": Destination id = " + - destId + " = " + GridSim.getEntityName(destId) ); - *********/ - - // create junk packets or empty FlowPacket. - for (i = 0; i < freq; i++) { - convertIntoPacket(MTU, numPackets+1, tag, destId, type); - } - } - // send to all resources + other entities - else if (pattern == TrafficGenerator.SEND_ALL) - { - // send to all resources and user entities - for (int k = 0; k < list_.size(); k++) - { - destId = ((Integer) list_.get(k)).intValue(); - - /********* // DEBUG info - System.out.println(super.get_name() + ": Destination id = " + - destId + " = " + GridSim.getEntityName(destId) ); - *********/ - - // create junk packets or empty FlowPacket. - for (i = 0; i < freq; i++) { - convertIntoPacket(MTU, numPackets+1, tag, destId, type); - } - } - } - - // sends the next junk packets - super.sim_schedule(super.get_id(), time, GridSimTags.JUNK_PKT); - } - - /** - * Initial start for the background traffic - * @pre $none - * @post $none - */ - // TODO: Background traffic not yet implemented, do not use! - private synchronized void startBackgroundTraffic() - { - // if no background traffic generator, then skip the rest - if (gen_ == null) { - return; - } - - // get the next inter-arrival time - long time = gen_.getNextPacketTime(); - System.out.println(super.get_name() + - ": background traffic will start at time " + time); - - // starts background traffic if the inter-arrival time is valid - if (time == -1) { - return; - } - - super.sim_schedule(super.get_id(), time, GridSimTags.JUNK_PKT); - } - - /** - * This method processes outgoing data without a network extension. - * @param ev a Sim_event object - * @param gisID the central/default GIS entity ID - * @param statID the GridStatistic entity ID - * @param shutdownID the GridSimShutdown entity ID - * @pre ev != null - * @post $none - */ - private synchronized void defaultSend(Sim_event ev, int gisID, int statID, - int shutdownID) - { - IO_data io = (IO_data) ev.get_data(); - int destId = io.getDestID(); - - /***** // DEBUG info*/ - System.out.println(super.get_name() + ".defaultSend(): Send to " + - GridSim.getEntityName(destId) + " tag = " + ev.get_tag() + " at time = " + GridSim.clock()); - /*****/ - - // if this entity uses a network extension - if (link_ != null && destId != gisID && destId != statID && - destId != shutdownID) - { - System.out.println(super.get_name() + ".defaultSend(): submitToLink() + at time = " + GridSim.clock()); - submitToLink(ev); - return; - } - -/* // Identify ID of an entity which acts as Input/Buffer - // entity of destination entity - int id = GridSim.getEntityId( "Input_" + - Sim_system.get_entity(destId).get_name() ); - - // Send first and then hold - super.sim_schedule(id, GridSimTags.SCHEDULE_NOW, ev.get_tag(), io); - - double receiverBaudRate = ( (FlowBuffer) - Sim_system.get_entity(id) ).getBaudRate(); - - // NOTE: io is in byte and baud rate is in bits. 1 byte = 8 bits - // So, convert io into bits - double minBaudRate = Math.min(baudRate_, receiverBaudRate); - double communicationDelay = GridSimRandom.realIO( - (io.getByteSize() * BITS) / minBaudRate); - - // NOTE: Below is a deprecated method for SimJava 2 - //super.sim_hold(communicationDelay); - super.sim_process(communicationDelay);*/ - } - - /** - * This method takes data from an entity. If the size of the data is larger - * than the MTU of the link, then the packet is split into mutiple size - * units. After this it calls outEnque() to queue these packets into its - * buffer. - * - * @param ev A Sim_event data that contains all the data for this method - * to do its task. - * @pre ev != null - * @post $none - */ - private synchronized void submitToLink(Sim_event ev) - { - IO_data data = (IO_data) ev.get_data(); - Object obj = data.getData(); - long size = data.getByteSize(); - int tag = ev.get_tag(); - int destId = data.getDestID(); - int netServiceType = data.getNetServiceLevel(); - - // we need to packetsize the data, all packets are sent with size MTU. - // only the last packet contains the data, the receiver should - // throw away all other packets - //int MTU = link_.getMTU(); - //int numPackets = (int) Math.ceil( size / (MTU * 1.0) ); - - // make dummy packets with null data - //System.out.println("Packetizing data, creating " + numPackets + " dummy packets at time = " + GridSim.clock()); - //convertIntoPacket(MTU, numPackets, tag, destId, netServiceType); - - // last packet contains the actual data - FlowPacket np = null; - np = new FlowPacket(obj,pktID_,size,tag,super.get_id(), - destId, netServiceType, 1, 1); - - System.out.println("Sending flow packet to link at time = " + GridSim.clock() + " id is " + pktID_); - pktID_++; // increments packet ID - outEnque(np, GridSimTags.SCHEDULE_NOW); - } - - private synchronized void submitAckToLink(Sim_event ev) - { - - FlowPacket fp = (FlowPacket)ev.get_data(); - System.out.println("Sending flow packet ack to link at time = " + GridSim.clock() + " id is " + pktID_); - outEnque(fp, GridSimTags.SCHEDULE_NOW); - } - - /** - * Creates many dummy or null packets - * @param size packet size (in bytes) - * @param numPackets total number of packets to be created - * @param tag packet tag - * @param destId destination ID for sending the packet - * @param netServiceType level type of service for the packet - * @pre $none - * @post $none - */ - private synchronized void convertIntoPacket(long size, int numPackets, - int tag, int destId, int netServiceType) - { - FlowPacket np = null; - for (int i = 0; i < numPackets - 1; i++) - { - // change the tag name for dummy packets, apart from junk packets - if (tag != GridSimTags.JUNK_PKT) { - tag = GridSimTags.EMPTY_PKT; - } - - np = new FlowPacket(null, pktID_, size, tag, super.get_id(), destId, - netServiceType, i+1, numPackets); - - pktID_++; // increments packet ID - outEnque(np, GridSimTags.SCHEDULE_NOW); - } - } - - /** - * Sends an InfoPacket for ping request - * @param ev a Sim_Event object - * @pre ev != null - * @post $none - */ - // TODO: Untested in flow model, and probably not useful - private synchronized void sendInfoPacket(Sim_event ev) - { - IO_data data = (IO_data) ev.get_data(); - - // gets all the relevant info - long size = data.getByteSize(); - int destId = data.getDestID(); - int netServiceType = data.getNetServiceLevel(); - int tag = ev.get_tag(); - String name = GridSim.getEntityName( outPort_.get_dest() ); - - // we need to packetsize the data, all packets are sent with size MTU - // only the last packet contains the ping data, the receiver should - // throw away all other data - int MTU = link_.getMTU(); - int numPackets = (int) Math.ceil( size / (MTU * 1.0) ); - - // break ping size into smaller pieces - // Also, make sure that it is not for pinging itself - if (size > MTU && outPort_.get_dest() != destId) - { - // make dummy packets with null data - convertIntoPacket(MTU, numPackets, tag, destId, netServiceType); - } - - // get the remaining ping size - size = data.getByteSize() - MTU*(numPackets-1); - - // create the real InfoPacket - InfoPacket pkt = new InfoPacket(name,pktID_,size,outPort_.get_dest(), - destId,netServiceType); - - // set the required info - pkt.setLast( super.get_id() ); - pkt.addHop( outPort_.get_dest() ); - pkt.addEntryTime( GridSim.clock() ); - pkt.setOriginalPingSize( data.getByteSize() ); - - pktID_++; // increments packet ID - outEnque(pkt, GridSimTags.SCHEDULE_NOW); - } - - /** - * Sends back the ping() request to the next hop or destination - * @param ev a Sim_event object - * @pre ev != null - * @post $none - */ - // TODO: Untested in flow model, and probably not useful - private void returnInfoPacket(Sim_event ev) - { - IO_data data = (IO_data) ev.get_data(); - - // use the original ping size rather than IO_data or InfoPacket size - // since the latter is restricted to MTU - InfoPacket pkt = (InfoPacket) data.getData(); - long size = pkt.getOriginalPingSize(); - - // get other relevant info - int tag = ev.get_tag(); - int destId = pkt.getSrcID(); - int netServiceType = data.getNetServiceLevel(); - - // we need to packetsize the data, all packets are sent with size MTU. - // only the last packet contains the data, the receiver should - // throw away all other packets - int MTU = link_.getMTU(); - int numPackets = (int) Math.ceil( size / (MTU * 1.0) ); - - // make dummy packets with null data - convertIntoPacket(MTU, numPackets, tag, destId, netServiceType); - - // set the original packet of last hop into this entity id - pkt.setLast( super.get_id() ); - outEnque(pkt, GridSimTags.SCHEDULE_NOW); - } - - /** - * Takes a packet, adds it into a buffer and schedules it to be sent out at - * an appropriate time. - * - * @param pkt The packet to be buffered - * @param delay The length of time this packet should be delayed (exclusive - * of the transmission time) - * @pre pkt != null - * @pre delay > 0 - * @post $none - */ - private synchronized void outEnque(Packet pkt, double delay) - { - - - outPacketList_.add(pkt); - if (outPacketList_.size() == 1) - { - System.out.println(super.get_name() + ".outEnque() Size is " + pkt.getSize() + " baud " + link_.getBaudRate()); - // Compute expected duration of flow using bottleneck baudRate - // double total = delay + (pkt.getSize()*SIZE / link_.getBaudRate()); - double total = 0.0; - - System.out.println(super.get_name() + ".outEnque() Time now " + GridSim.clock() + " delay is " + total); - super.sim_schedule(super.get_id(), total, GridSimTags.SEND_PACKET); - } - - } - - - /** - * Removes a single packet from the buffer and sends it down the link. - * Then, schedules the next packet in the list. - * @pre $none - * @post $none - */ - private synchronized void sendPacket() - { - if (outPacketList_ == null || outPacketList_.isEmpty() == true) { - return; - } - - // submits the first packet in the list - Packet np = (Packet) outPacketList_.remove(0); - - boolean ping = false; // a flag to determine ping packet or not - int tag = -1; // event tag ID - int dest = -1; // destination ID - - // if a packet belongs to a ping packet - if (np instanceof InfoPacket) - { - ((InfoPacket)np).addExitTime( GridSim.clock() ); - ((InfoPacket)np).addBaudRate( link_.getBaudRate() ); - ping = true; - tag = GridSimTags.INFOPKT_SUBMIT; - } - - // if an entity tries to send a packet to itself - if ( np.getDestID() == outPort_.get_dest() ) - { - // then change the destination name and id - String destName = super.get_name(); - destName = destName.replaceFirst("Output", "Input"); - dest = Sim_system.get_entity_id(destName); - - // for a ping packet, change the tag - if (ping == true) - { - // don't forget to change the packet tag - tag = GridSimTags.INFOPKT_RETURN; - ((InfoPacket) np).setTag(tag); - } - else { - tag = np.getTag(); - } - } - else // if an entity tries to send to other entity - { - // change or keep the event tag - tag = GridSimTags.PKT_FORWARD; - if (np.getTag() == GridSimTags.JUNK_PKT) { - tag = GridSimTags.JUNK_PKT; - } - - // sends the packet into the link - dest = link_.get_id(); - } - - // send the packet - super.sim_schedule(dest, GridSimTags.SCHEDULE_NOW, tag, np); - - /***** // DEBUG info **/ - System.out.println(super.get_name() + " send to " + - GridSim.getEntityName(dest) + " tag = " + tag + " time " + GridSim.clock()); - /****/ - - // if the list is not empty, then schedule the next packet in the list - if (outPacketList_.isEmpty() != true) - { - //double delay = np.getSize() * SIZE / link_.getBaudRate(); - double delay = 0.0; - super.sim_schedule(super.get_id(), delay, GridSimTags.SEND_PACKET); - } - } - - /** - * Process incoming events from senders that are using the network - * extension - * @param ev a Sim_event object - * @pre ev != null - * @post $none - */ - private void getDataFromLink(Sim_event ev) - { - Object obj = ev.get_data(); - double duration = 0.0; - - if (obj instanceof Packet) - { - // decrypt the packet into original format - Packet pkt = (Packet) ev.get_data(); - - if (pkt instanceof InfoPacket) - { - processPingRequest( (InfoPacket) pkt); - return; - } - - if (pkt instanceof FlowPacket) - { - FlowPacket np = (FlowPacket) pkt; - int tag = np.getTag(); - System.out.println("Packet id is " + np.getID()); - - // ignore incoming junk packets - if (tag == GridSimTags.JUNK_PKT) { - return; - } - - // ignore incoming null dummy packets - if (tag == GridSimTags.EMPTY_PKT && np.getData() == null) { - return; - } - - // convert the packets into IO_data - Object data = np.getData(); - IO_data io = new IO_data( data, np.getSize(), - outPort_.get_src()); - System.out.println(super.get_name() + ".getDataFromLink() Time now " + GridSim.clock() - + " bottleneck is " + np.getBandwidth_() + " sum lat is " + np.getLatency() ); - - // if flow terminates at next entity, add to active flows - // & hold for appropriate duration - if (pkt.getTag() == GridSimTags.FLOW_SUBMIT) { - np.setStartTime(GridSim.clock()); - np.setUpdateTime(GridSim.clock()); - duration = np.getSize()*SIZE / np.getBandwidth_(); - activeFlows_.put(pkt.getID(), pkt); - super.sim_schedule(super.get_id(), duration, GridSimTags.FLOW_HOLD, new Integer(pkt.getID())); - System.out.println(super.get_name() + ".getDataFromLink() forecast flow end at " + (GridSim.clock() - + duration)); - - // if flow is just an ACK of a finished flow do not hold - } else if (pkt.getTag() == GridSimTags.FLOW_RETURN){ - duration = 0.0; - // send the data into entity input/output port - super.sim_schedule(outPort_, duration, tag, - io.getData() ); - } - - - } - } - } - - /** - * Processes a ping request - * @param pkt a packet for pinging - * @pre pkt != null - * @post $none - */ - // TODO: Untested in flow model, and probably not useful - private void processPingRequest(InfoPacket pkt) - { - // add more information to ping() packet - pkt.addHop( outPort_.get_dest() ); - pkt.addEntryTime( GridSim.clock() ); - - IO_data io = new IO_data( pkt, pkt.getSize(), outPort_.get_dest() ); - - // send this ping() packet to the entity - super.sim_schedule(outPort_, GridSimTags.SCHEDULE_NOW, - pkt.getTag(), io.getData()); - } - -} // end class - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-03-18 00:40:33
|
Revision: 161 http://gridsim.svn.sourceforge.net/gridsim/?rev=161&view=rev Author: marcos_dias Date: 2008-03-17 17:40:38 -0700 (Mon, 17 Mar 2008) Log Message: ----------- This update contains: + An additional item in the Options menu at the ResourceWindow that allows the user to visualise to which partition the jobs belong + A bug fix in the advance reservation features of the multiple partition policies. There were overlaps of advance reservations and normal jobs when using advance reservations. The transfer of PEs to the queue to which the advance reservation belongs, was not being done correctly. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-18 00:40:38 UTC (rev 161) @@ -96,10 +96,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-18 00:40:38 UTC (rev 161) @@ -96,10 +96,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-18 00:40:38 UTC (rev 161) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-03-18 00:40:38 UTC (rev 161) @@ -43,12 +43,17 @@ private Composite transparentComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); - private final Color[] colorQueued = createPalette(153, 153, 255, 40, 6); - private final Color[] colorDone = createPalette(204, 204, 204, 30, 6); - private final Color[] colorInExec = createPalette(255, 255, 102, 25, 6); - private final Color[] colorARNonCommitted = createPalette(153, 255, 153, 51, 6); - private final Color[] colorARCommitted = createPalette(153, 255, 255, 51, 6); - private final Color[] colorARInProgress = createPalette(255, 102, 102, 25, 6); + private final int colorPerPalette = 6; + private final Color[] colorQueued = createPalette(153, 153, 255, 40, colorPerPalette); + private final Color[] colorDone = createPalette(204, 204, 204, 30, colorPerPalette); + private final Color[] colorInExec = createPalette(255, 255, 102, 25, colorPerPalette); + private final Color[] colorARNonCommitted = createPalette(153, 255, 153, 51, colorPerPalette); + private final Color[] colorARCommitted = createPalette(153, 255, 255, 51, colorPerPalette); + private final Color[] colorARInProgress = createPalette(255, 102, 102, 25, colorPerPalette); + private final Color[] colorQueues = + new Color[]{Color.WHITE, Color.RED, Color.GREEN, Color.CYAN, + Color.DARK_GRAY, Color.MAGENTA, Color.ORANGE, Color.PINK, + Color.YELLOW, Color.BLUE}; private static GUISettings settingsInstance_ = null; @@ -63,7 +68,7 @@ return settingsInstance_; } - + /** * Gets the time span for the GUI components * @return the time span for the GUI components @@ -238,6 +243,13 @@ return colors; } + /** + * Return the colours to be used for the partitions + * @return the colors for the partitions + */ + public Color[] getQueueColors() { + return this.colorQueues; + } /** * Returns an array of colours Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-03-18 00:40:38 UTC (rev 161) @@ -110,6 +110,7 @@ private boolean drawID_ = true; private boolean autoScroll_ = true; private boolean animate_ = true; + private boolean showPartition_ = false; private JButton btSetSdWindowSize_; private JTextField fdSdWindowSize_; @@ -142,6 +143,7 @@ private Color[] colorsARNonCommitted; private Color[] colorsARCommitted; private Color[] colorsARInProgress; + private Color[] colorQueues; private static final int WINDOW_WIDTH = 900; private static final int WINDOW_HEIGHT = 350; @@ -185,6 +187,7 @@ colorsARNonCommitted = settings_.getARNonCommittedColors(); colorsARCommitted = settings_.getARCommittedColors(); colorsARInProgress = settings_.getARInProgressColors(); + colorQueues = settings_.getQueueColors(); } // -------------------------- PUBLIC METHODS ----------------------- @@ -476,6 +479,25 @@ menuCommand.add(mnAnimation); + JMenu mnPartition = new JMenu("Partitions"); + JCheckBoxMenuItem miPartition = new JCheckBoxMenuItem("Show Partition Informations"); + miPartition.setSelected(false); + mnPartition.add(miPartition); + + miPartition.addItemListener(new ItemListener(){ + public void itemStateChanged(ItemEvent e){ + if (e.getStateChange() == ItemEvent.DESELECTED){ + showPartition_ = false; + } + else if (e.getStateChange() == ItemEvent.SELECTED){ + showPartition_ = true; + } + updateResourceWindow(); + } + }); + + menuCommand.add(mnPartition); + menuBar.add(menuCommand); setJMenuBar(menuBar); } @@ -698,10 +720,13 @@ continue; int itemId = item.getID(); - if (item.getPERangeList() != null){ + if (item.getPERangeList() != null) { // the color of the font for normal gridlets is black fontColor = Color.BLACK; - if(!item.isAdvanceReservation()) { + if(showPartition_) { + boxColor = colorQueues[item.getPartitionID() % colorQueues.length]; + } + else if(!item.isAdvanceReservation()) { // Gridlet is in execution if(item.getStatus() == Gridlet.INEXEC){ boxColor = colorsInExec[(itemId % colorsInExec.length)]; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -302,6 +302,9 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); + if(startTime == 0) + startTime = currentTime; + // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); @@ -335,8 +338,8 @@ boolean success = true; - // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + // if start time = current time, then it is an immediate reservation + if(startTime == currentTime) { success = handleImmediateReservation(sRes); expTime = sRes.getActualFinishTime(); } @@ -1088,19 +1091,31 @@ tailIndex, selected, startTime, res.getActualFinishTime()); } else { + + // number of additional PEs required + int addRequired = reqPE - ranges.getNumPE(); - // check when enough PEs to handle the gridlet will be available + // check when enough PEs to handle the gridlet will be available // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(startTime, duration); + // removes PEs already obtained from selected partition PERangeList addRanges = availObj == null ? - new PERangeList() : (PERangeList)availObj[2]; + new PERangeList() : + PERangeList.difference((PERangeList)availObj[2], ranges); - if(addRanges.getNumPE() < reqPE) - return false; + if(addRanges == null || addRanges.getNumPE() < addRequired) + return false; - addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + // selects and transfers PEs to the queue o which the AR belongs + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, + startTime, startTime + duration); + + // now get the availability of the queue again + availObj = profile_.checkPERangesAvailability(queueId, + startTime, duration); // the anchor index, the entry in the profile where // the gridlet will be placed @@ -1109,16 +1124,11 @@ // corresponding to the gridlet's finish time will be placed int tailIndex = (Integer)availObj[1]; - // borrows the ranges from the queues and adds it into the - // specified queue - profile_.transferPEs(queueId, addRanges, startTime, - startTime + duration); - // finally allocate the ranges to the gridlet - ranges.addAll(addRanges); + ranges = super.selectPERangeList(reqPE, (PERangeList)availObj[2]); profile_.allocatePERanges(queueId, anchorIndex, tailIndex, - ranges, startTime, startTime + duration); + ranges, startTime, startTime + duration); res.setPERangeList(ranges); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -306,6 +306,9 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); + if(startTime == 0) + startTime = currentTime; + // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); @@ -337,10 +340,10 @@ return; } - boolean success = true; + boolean success = false; - // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + // if start time = current time, then it is an immediate reservation + if(startTime == currentTime) { success = handleImmediateReservation(sRes); expTime = sRes.getActualFinishTime(); } @@ -917,7 +920,8 @@ //-------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- // If a gridlet has been cancelled, then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, removedRes); + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_CANCELLED, true, removedRes); //----------------------------------------------------------------- @@ -930,7 +934,8 @@ // If a gridlet has started execution or one has finished, // then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + GridSim.notifyListeners(this.get_id(), + AllocationAction.SCHEDULE_CHANGED, true); //----------------------------------------------------------------- } @@ -1093,37 +1098,44 @@ tailIndex, selected, startTime, res.getActualFinishTime()); } else { - - // check when enough PEs to handle the gridlet will be available + + // number of additional PEs required + int addRequired = reqPE - ranges.getNumPE(); + + // check when enough PEs to handle the gridlet will be available // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(startTime, duration); - + + // removes PEs already obtained from selected partition PERangeList addRanges = availObj == null ? - new PERangeList() : (PERangeList)availObj[2]; + new PERangeList() : + PERangeList.difference((PERangeList)availObj[2], ranges); - if(addRanges.getNumPE() < reqPE) + if(addRanges == null || addRanges.getNumPE() < addRequired) return false; - - addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + // selects and transfers PEs to the queue o which the AR belongs + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, + startTime, startTime + duration); + + // now get the availability of the queue again + availObj = profile_.checkPERangesAvailability(queueId, + startTime, duration); + // the anchor index, the entry in the profile where // the gridlet will be placed int anchorIndex = (Integer)availObj[0]; // insert index represents the position after which the entry // corresponding to the gridlet's finish time will be placed int tailIndex = (Integer)availObj[1]; - - // borrows the ranges from the queues and adds it into the - // specified queue - profile_.transferPEs(queueId, addRanges, startTime, - startTime + duration); - + // finally allocate the ranges to the gridlet - ranges.addAll(addRanges); + ranges = super.selectPERangeList(reqPE, (PERangeList)availObj[2]); profile_.allocatePERanges(queueId, anchorIndex, tailIndex, - ranges, startTime, startTime + duration); + ranges, startTime, startTime + duration); res.setPERangeList(ranges); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-18 00:40:38 UTC (rev 161) @@ -1322,10 +1322,6 @@ tailIndex++; } - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - if (anchorIndex > -1) { AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); @@ -1356,6 +1352,10 @@ availProfile_.add(anchorIndex, newEntryAfterAnchor); tailIndex++; } + + if(addEntryAfterTail) { + availProfile_.add(tailIndex, newEntryAfterTail); + } // Update entries of the profile if(tailIndex > -1) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -411,6 +411,39 @@ // --------------------- PROTECTED METHODS ----------------------- + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether there are + * gridlets in the waiting list that should start execution. It also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + + double currentTime = GridSim.clock(); + + // then finishes the Gridlets whose start time is smaller + // or equals to the current simulation time + int itemsFinished = finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + MPProfileEntry currentStatus = profile_.removePastEntries(currentTime); + if(currentStatus != null) { + profile_.setCurrentStatus(currentStatus); + resource_.resetFreePERanges(currentStatus.getPERanges()); + } + + // Start the execution of Gridlets that are queued and whose + // potential start execution time is smaller than current time + int itemsStarted = startQueuedGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0){ + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + } + } /** * This method finalises the gridlets in execution whose time Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -93,7 +93,7 @@ // indicates whether the borrowing of resources by the // partitions is allowed or not - private boolean allowBorrowing_; + protected boolean allowBorrowing_; // the number of partitions or queues in this scheduler protected int numPartitions_; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-18 00:40:38 UTC (rev 161) @@ -214,7 +214,7 @@ if (tailEntry == null) { MPProfileEntry newTail = createHeadEntry(finishTime); - super.add(super.indexOf(tailEntry) + 1, newTail); + super.add(0, newTail); } else if(tailEntry.getTime() < finishTime) { MPProfileEntry newTail = tailEntry.clone(finishTime); @@ -520,11 +520,11 @@ } /** - * Allocate processing elements to a gridlet + * Allocate processing elements to a gridlet/reservation * @param queueId the id of the gridlet's selected partition * @param anchorIndex the index of the entry used as anchor - * @param tailIndex the index of the last entry close to the gridlet's - * finish time + * @param tailIndex the index of the last entry close to the + * gridlet's finish time * @param selected the selected ranges of PEs * @param startTime the gridlet's start time * @param finishTime the gridlet's finish time @@ -573,10 +573,6 @@ tailIndex++; } - if(addEntryAfterTail) { - super.add(tailIndex, newEntryAfterTail); - } - if (anchorIndex > -1) { MPProfileEntry anchorEntry = super.get(anchorIndex); @@ -605,6 +601,10 @@ super.add(anchorIndex, newEntryAfterAnchor); tailIndex++; } + + if(addEntryAfterTail) { + super.add(tailIndex, newEntryAfterTail); + } // Update entries of the profile if(tailIndex > -1) { @@ -865,6 +865,23 @@ public void transferPEs(int recQueueId, PERangeList list, double startTime, double finishTime) { +// // creates a new entry to be used as the tail for the +// // time slot transfered to another queue. This is required to +// // mark the finish time of a slot given to an advance reservation +// MPProfileEntry tailEntry = getPrecedingEntry(finishTime); +// if(tailEntry != null && tailEntry.getTime() < finishTime) { +// int newTailIndex = super.indexOf(tailEntry) + 1; +// MPProfileEntry newTailEntry = tailEntry.clone(finishTime); +// super.add(newTailIndex, newTailEntry); +// } +// else if (tailEntry != null && tailEntry.getTime() == finishTime) { +// tailEntry.increaseGridlet(); +// } +// else if (tailEntry == null) { +// MPProfileEntry newTailEntry = createHeadEntry(finishTime); +// super.add(0, newTailEntry); +// } + // if start time is equals to current time, then we have // to transfer ranges across the idle pes as well if(startTime <= GridSim.clock()) { @@ -877,15 +894,32 @@ queue.getIdlePERanges().addAll(list.clone()); queue.getIdlePERanges().mergePERanges(); } + else { + // creates a new entry to be used as anchor for the + // time slot transfered to another queue. This is required to + // mark the start time of a slot given to an advance reservation + MPProfileEntry anchorEntry = getPrecedingEntry(startTime); + + if (anchorEntry == null) { + MPProfileEntry newAnchorEntry = createHeadEntry(startTime); + super.add(0, newAnchorEntry); + } + else if(anchorEntry.getTime() < startTime) { + MPProfileEntry newAnchorEntry = anchorEntry.clone(startTime); + super.add(super.indexOf(anchorEntry) + 1, newAnchorEntry); + } + } // transfer the ranges for(int i=0; i<super.size(); i++) { MPProfileEntry nextEntry = super.get(i); - if(nextEntry.getTime() < startTime) + if(nextEntry.getTime() < startTime) { continue; - if(nextEntry.getTime() >= finishTime) + } + if(nextEntry.getTime() >= finishTime) { // if(nextEntry.getTime() > finishTime) break; + } else { nextEntry.transferPEs(recQueueId, list); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-14 06:26:16
|
Revision: 160 http://gridsim.svn.sourceforge.net/gridsim/?rev=160&view=rev Author: brobergj Date: 2008-03-13 23:26:19 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Minor fixes and javadoc comments Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FilterFlow.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FilterFlow.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FilterFlow.java 2008-03-14 01:06:34 UTC (rev 159) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FilterFlow.java 2008-03-14 06:26:19 UTC (rev 160) @@ -29,7 +29,7 @@ * * * @author James Broberg - * @since GridSim Toolkit 4.0 + * @since GridSim Toolkit 5.0 * @invariant $none */ public class FilterFlow extends Sim_predicate Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java 2008-03-14 01:06:34 UTC (rev 159) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java 2008-03-14 06:26:19 UTC (rev 160) @@ -1,10 +1,14 @@ /* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * ** Network and Service Differentiation Extensions to GridSim 4.0 ** * - * $Id: Input.java,v 1.7 2005/09/02 04:12:04 anthony Exp $ + * Author: James Broberg (based on Input.java) + * + * March 2007 + * + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * FlowInput.java - Simulates a network input port + * */ package gridsim.net.flow; @@ -19,19 +23,19 @@ import eduni.simjava.*; /** - * GridSim Input class defines a port through which a simulation entity + * GridSim FlowInput class defines a port through which a simulation entity * receives data from the simulated network. * <p> * It maintains an event queue * to serialize the data-in-flow and delivers to its parent entity. - * It accepts messages that comes from GridSim entities 'Output' entity + * It accepts messages that comes from GridSim entities 'FlowOutput' entity * and passes the same to the GridSim entity. - * It simulates Network communication delay depending on Baud rate + * It simulates Network communication delay depending on current bottleneck Baud rate * and data length. Simultaneous inputs can be modeled using multiple * instances of this class. * - * @author Manzur Murshed and Rajkumar Buyya - * @since GridSim Toolkit 1.0 + * @author James Broberg + * @since GridSim Toolkit 5.0 * @invariant $none */ public class FlowInput extends Sim_entity implements NetIO @@ -47,7 +51,7 @@ /** - * Allocates a new Input object + * Allocates a new FlowInput object * @param name the name of this object * @param baudRate the communication speed * @throws NullPointerException This happens when creating this entity @@ -71,9 +75,9 @@ } /** - * Sets the Input entities link. This should be used only if the network + * Sets the FlowInput entities link. This should be used only if the network * extensions are being used. - * @param link the link to which this Input entity should send data + * @param link the link to which this FlowInput entity should send data * @pre link != null * @post $none */ @@ -131,7 +135,7 @@ /** * This is an empty method and only applicable to - * {@link gridsim.net.Output} class. + * {@link gridsim.net.FlowOutput} class. * @param gen a background traffic generator * @param userName a collection of user entity name (in String object). * @return <tt>false</tt> since this method is not used by this class. @@ -182,11 +186,11 @@ // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { break; - // Check if initial flow duration estimation was accurate + // Check forecast of active flow and pass it onto Entity if still active } else if(ev.get_tag() == GridSimTags.FLOW_HOLD) { System.out.println(super.get_name() + ".body(): checkForecast() + at time = " + GridSim.clock()); checkForecast(ev); - // Update flow duration forecast + // Update flow duration forecast as a flow's bottleneck bandwidth has changed } else if (ev.get_tag() == GridSimTags.FLOW_UPDATE) { System.out.println(super.get_name() + ".body(): updateForecast() + at time = " + GridSim.clock()); updateForecast(ev); @@ -217,7 +221,6 @@ private void checkForecast(Sim_event ev) { int pktID = (Integer) ev.get_data(); // ID of flow to be checked FlowPacket fp = null; // Reference to flow packet that needs forecast update - FlowPacket fpAck = null; System.out.println(super.get_name() + ".checkForecast(): checking pkt id # " + pktID); @@ -229,7 +232,6 @@ super.sim_schedule(inPort_, GridSimTags.SCHEDULE_NOW, fp.getTag() , io.getData()); activeFlows_.remove(pktID); - // Send ack to source of flow System.out.println(super.get_name() + ".checkForecast(): flow came from " + GridSim.getEntityName(fp.getSrcID()) + " heading to " + GridSim.getEntityName(fp.getDestID())); @@ -239,26 +241,7 @@ FlowLink fl = (FlowLink) it.next(); fl.deregisterFlow(fp); } - - /* - int oldDestID = fp.getDestID(); - int oldSrcID = fp.getSrcID(); - - IO_data ackData = new IO_data(fp.getData(), fp.getSize(), oldSrcID-2); - fpAck = new FlowPacket(ackData,fp.getID(),fp.getSize(),GridSimTags.FLOW_RETURN,oldDestID+2, - oldSrcID-2, fp.getNetServiceType(), 1, 1); - fpAck.setSize(fp.getSize()); - fpAck.setRemSize(0); - fpAck.setStartTime(fp.getStartTime()); - fpAck.setLatency(fp.getLatency()); - - System.out.println("Sending flow packet ack to link at time = " + GridSim.clock() + " id is " - + fpAck.getID()); - super.sim_schedule(GridSim.getEntityId("Output_" + GridSim.getEntityName(oldDestID)), - GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_ACK, fpAck); - - //super.sim_schedule(super.get_id(), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_ACK, fpAck); */ - + } else { System.out.println(super.get_name() + ".checkForecast(): pkt id # " + pktID + " already removed"); @@ -267,8 +250,9 @@ } /** - * Update the forecast of a flow, delete the old forecast and schedule a new flow hold - * event in the future with the corrected forecast + * Update the forecast of a flow by deleting the old forecast and scheduling a new flow hold + * event in the future with the corrected forecast (based on new bottleneck bandwidth and + * the amount of flow already sent) * * @param ev the flow update notification event * @pre ev != null @@ -293,6 +277,7 @@ "BW old is " + bandwidthOld + " last update " + fp.getUpdateTime()); Iterator it = (fp.getLinks_()).iterator(); + // Find the source link of this notification and the associated bottleneck bandwidth while (it.hasNext()) { FlowLink fl = (FlowLink) it.next(); if (fl.get_id() == sourceID) { @@ -305,6 +290,7 @@ duration = (fp.getRemSize()*BITS)/fp.getBandwidth_(); System.out.println(super.get_name() + " new forecast end time is " + (GridSim.clock() + duration)); + // Find old forecast and delete it! FilterFlow filter = new FilterFlow(fp.getID(), GridSimTags.FLOW_HOLD); cancelledFlow = this.sim_cancel(filter, null); @@ -314,7 +300,9 @@ } System.out.println(super.get_name() + " setting updated forecast for packet #" + fp.getID()); + // Make a note of the time when this forecast update was performed fp.setUpdateTime(GridSim.clock()); + // Set new future event with the correct finish time super.sim_schedule(super.get_id(), duration, GridSimTags.FLOW_HOLD , new Integer(fp.getID())); } Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-03-14 01:06:34 UTC (rev 159) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-03-14 06:26:19 UTC (rev 160) @@ -3,11 +3,11 @@ * * Author: James Broberg * - * August 2007 + * March 2007 * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * FlowLink.java - Simulates a network link with active flows + * FlowLink.java - Simulates a network link with active flows (based on SimpleLink.java) * */ @@ -27,14 +27,14 @@ * on SimpleLink.java by Gokul Poduval & Chen-Khong Tham * * @invariant $none - * @since GridSim Toolkit 4.0 + * @since GridSim Toolkit 5.0 * @author James Broberg, The University of Melbourne */ public class FlowLink extends Link { private Vector q_; - private HashMap flows_; // Stores references to flows that are currently active on this link + private HashMap activeFlows_; // Stores references to flows that are currently active on this link private double lastUpdateTime_; // a timer to denote the last update time private int inEnd1_; private int outEnd1_; @@ -107,7 +107,7 @@ { lastUpdateTime_ = 0.0; q_ = new Vector(); - flows_ = new HashMap(); + activeFlows_ = new HashMap(); inEnd1_ = -1; outEnd1_ = -1; inEnd2_ = -1; @@ -334,7 +334,7 @@ { System.out.println(super.get_name() + " enque() + at time = " + GridSim.clock()); int tag = ((Packet)ev.get_data()).getTag(); - // Register passing flow as active on this link + // Register passing flow, gridlet or junk as active on this link if (tag == GridSimTags.FLOW_SUBMIT || tag == GridSimTags.GRIDLET_SUBMIT || tag == GridSimTags.GRIDLET_SUBMIT_ACK || tag == GridSimTags.GRIDLET_RETURN || tag == GridSimTags.JUNK_PKT) { @@ -389,13 +389,6 @@ tag = np.getTag(); } - - //if (np.getTag() == GridSimTags.FLOW_RETURN) { - // System.out.println(super.get_name() + ".deque() Dereg flow # " + np.getID() +" here"); - // Deregister passing flow as it is now de-active on this link - // ((FlowPacket)np).addLatency(this.getDelay()); - // deregisterFlow(np); - //} // sends the packet super.sim_schedule(dest, GridSimTags.SCHEDULE_NOW, tag, np); @@ -430,7 +423,9 @@ } /** - * Registers active flow to link, and link to flow + * Registers active flow to the link, and the link to flow. + * Notifies the destination of any active flows if the bottleneck + * bandwidth is changed. * @param np a packet * @pre $none * @post $none @@ -440,18 +435,18 @@ FlowPacket tempFlow = null; // Add flow to link - flows_.put(np.getID(), np ); + activeFlows_.put(np.getID(), np ); System.out.println(super.get_name() + ".registerFlow(): registering flow #" + np.getID() - + " total of " + flows_.size() + " flows"); + + " total of " + activeFlows_.size() + " flows"); // Register link to flow ((FlowPacket)np).addLink(this); // Check if this affects any existing flows - Iterator<Integer> flowsIter = flows_.keySet().iterator(); + Iterator<Integer> flowsIter = activeFlows_.keySet().iterator(); while(flowsIter.hasNext()) { - tempFlow = (FlowPacket) flows_.get(flowsIter.next()); + tempFlow = (FlowPacket) activeFlows_.get(flowsIter.next()); // If change in bandwidth affects an existing flow i.e. is < current bottleneck if (this.getBaudRate() < tempFlow.getBandwidth_() && tempFlow.getID() != np.getID()) { // Need to notify flow @@ -468,7 +463,8 @@ } /** - * Deregisters active flow on link + * Deregisters active flow on link. Notifies the destination of any active + * flows if the bottleneck bandwidth is changed. * @param np a packet * @pre $none * @post $none @@ -477,15 +473,16 @@ FlowPacket fp = null; FlowPacket tempFlow; - if ((fp = (FlowPacket) flows_.remove(np.getID())) != null) { + // If the flow hasn't been removed already, remove from active flow list + if ((fp = (FlowPacket) activeFlows_.remove(np.getID())) != null) { System.out.println(super.get_name() + ".deregisterFlow() success flow # " + np.getID() + " " + fp.getBandwidth_()); // Check if this affects any existing flows - Iterator<Integer> flowsIter = flows_.keySet().iterator(); + Iterator<Integer> flowsIter = activeFlows_.keySet().iterator(); while(flowsIter.hasNext()) { - tempFlow = (FlowPacket) flows_.get(flowsIter.next()); + tempFlow = (FlowPacket) activeFlows_.get(flowsIter.next()); // If change in bandwidth affects an existing flow i.e. is > current bottleneck // AND this link is the particular flow's bottleneck if (this.getBaudRate() > tempFlow.getBandwidth_() && tempFlow.getID() != np.getID() && @@ -507,14 +504,14 @@ /** * Returns available baudRate depending on number of - * active flows + * active flows (MIN_MAX bandwidth sharing model) * @pre $none * @post $none */ public synchronized double getBaudRate() { - if (flows_.size() != 0) { - System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)/(flows_.size())); - return (super.baudRate_)/(flows_.size()); + if (activeFlows_.size() != 0) { + System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)/(activeFlows_.size())); + return (super.baudRate_)/(activeFlows_.size()); } else { System.out.println(super.get_name() + ".getBaudRate() Getting latest baud! " + (super.baudRate_)); return super.baudRate_; Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java 2008-03-14 01:06:34 UTC (rev 159) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java 2008-03-14 06:26:19 UTC (rev 160) @@ -1,10 +1,14 @@ /* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * ** Network and Service Differentiation Extensions to GridSim 4.0 ** * - * $Id: Output.java,v 1.7 2005/09/02 04:12:04 anthony Exp $ + * Author: James Broberg + * + * March 2007 + * + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * FlowOutput.java - Simulates a network output port + * */ package gridsim.net.flow; @@ -20,17 +24,17 @@ /** - * GridSim Output defines a port through which a simulation entity sends + * GridSim FlowOutput defines a port through which a simulation entity sends * data to the simulated network. * <p> * It maintains an event queue to serialize * the data-out-flow and delivers to the destination entity. - * It works along with Input entity to simulate network + * It works along with FlowInput entity to simulate network * communication delay. Simultaneous outputs can be modeled by using multiple * instances of this class * - * @author Manzur Murshed and Rajkumar Buyya - * @since GridSim Toolkit 1.0 + * @author James Broberg + * @since GridSim Toolkit 5.0 * @invariant $none */ public class FlowOutput extends Sim_entity implements NetIO @@ -40,18 +44,19 @@ private double baudRate_; // baud rate of this entity private final int SIZE = 8; // 1 byte in bits private static int pktID_ = 0; // packet ID counter - private Vector packetList_; // store a list of packets + private Vector flowList_; // store a list of packets private Random random_; // selects to which junk packets go to private TrafficGenerator gen_; // background traffic generator private ArrayList list_; // list of resources + user entities private boolean hasStarted_; // a flag for background traffic has started private static final int BITS = 8; // 1 byte = 8 bits - private Random rnd; + private Random rnd; // Random number generator to generate unique + // flow ID's /** - * Allocates a new Output object + * Allocates a new FlowOutput object * @param name the name of this object * @param baudRate the communication speed * @throws NullPointerException This happens when creating this entity @@ -66,7 +71,7 @@ super(name); this.baudRate_ = baudRate; link_ = null; - packetList_ = null; + flowList_ = null; pktID_ = 0; outPort_ = new Sim_port("output_buffer"); @@ -187,7 +192,7 @@ { this.link_ = link; baudRate_ = link_.getBaudRate(); - packetList_ = new Vector(); + flowList_ = new Vector(); } /** @@ -286,12 +291,6 @@ case GridSimTags.JUNK_PKT: generateBackgroundTraffic(); break; - - // activate background traffic - //case GridSimTags.FLOW_ACK: - // System.out.println((FlowPacket) ev.get_data()); - // enque((FlowPacket) ev.get_data(),GridSimTags.SCHEDULE_NOW); - // break; default: defaultSend(ev, gisID, statID, shutdownID); @@ -301,7 +300,7 @@ } /** - * Generates few junk packets at the given interval + * Generates few junk flows at the given interval * @pre $none * @post $none */ @@ -342,11 +341,6 @@ int type = gen_.getServiceType(); // packet type int tag = GridSimTags.JUNK_PKT; // packet tag - // we need to packetsize the data, all packets are sent with size MTU. - // only the last packet contains the data, the receiver should - // throw away all other packets - // int MTU = link_.getMTU(); - // int numPackets = (int) Math.ceil( size / (MTU * 1.0) ); /********* // DEBUG info System.out.println(); @@ -371,11 +365,6 @@ System.out.println(super.get_name() + ": Destination id = " + destId + " = " + GridSim.getEntityName(destId) ); *********/ - - // create junk packets or empty NetPacket. - //for (i = 0; i < freq; i++) { - // convertIntoPacket(MTU, numPackets+1, tag, destId, type); - //} convertIntoPacket(size, 1, tag, destId, type); @@ -394,10 +383,6 @@ destId + " = " + GridSim.getEntityName(destId) ); *********/ - // create junk packets or empty NetPacket. - //for (i = 0; i < freq; i++) { - // convertIntoPacket(MTU, numPackets+1, tag, destId, type); - //} convertIntoPacket(size, 1, tag, destId, type); } @@ -447,7 +432,7 @@ IO_data io = (IO_data) ev.get_data(); int destId = io.getDestID(); - /***** // DEBUG info*/ + /***** // DEBUG info System.out.println(super.get_name() + ".defaultSend(): Send to " + GridSim.getEntityName(destId) + " tag = " + ev.get_tag() + " at time = " + GridSim.clock()); /*****/ @@ -484,9 +469,8 @@ } /** - * This method takes data from an entity. If the size of the data is larger - * than the MTU of the link, then the packet is split into mutiple size - * units. After this it calls outEnque() to queue these packets into its + * This method takes data from an entity. The data is encapsulated in a single FlowPacket. + * After this it calls enque() to queue these flows into its * buffer. * * @param ev A Sim_event data that contains all the data for this method @@ -503,24 +487,13 @@ int destId = data.getDestID(); int netServiceType = data.getNetServiceLevel(); - // we need to packetsize the data, all packets are sent with size MTU. - // only the last packet contains the data, the receiver should - // throw away all other packets - //int MTU = link_.getMTU(); - //int numPackets = (int) Math.ceil( size / (MTU * 1.0) ); - - // make dummy packets with null data - //System.out.println("Packetizing data, creating " + numPackets + " dummy packets at time = " + GridSim.clock()); - //convertIntoPacket(MTU, numPackets, tag, destId, netServiceType); - // last packet contains the actual data FlowPacket np = null; - np = new FlowPacket(obj,rnd.nextInt(10000000),size,tag,super.get_id(), + np = new FlowPacket(obj,rnd.nextInt(Integer.MAX_VALUE),size,tag,super.get_id(), destId, netServiceType, 1, 1); System.out.println("Sending flow packet to link at time = " + GridSim.clock() + " id is " + np.getID()); - pktID_++; // increments packet ID enque(np, GridSimTags.SCHEDULE_NOW); } @@ -649,12 +622,10 @@ { - packetList_.add(pkt); - if (packetList_.size() == 1) + flowList_.add(pkt); + if (flowList_.size() == 1) { System.out.println(super.get_name() + ".enque() Size is " + pkt.getSize() + " baud " + link_.getBaudRate()); - // Compute expected duration of flow using bottleneck baudRate - // double total = delay + (pkt.getSize()*SIZE / link_.getBaudRate()); double total = 0.0; System.out.println(super.get_name() + ".enque() Time now " + GridSim.clock() + " delay is " + total); @@ -671,12 +642,12 @@ */ private synchronized void sendPacket() { - if (packetList_ == null || packetList_.isEmpty() == true) { + if (flowList_ == null || flowList_.isEmpty() == true) { return; } // submits the first packet in the list - Packet np = (Packet) packetList_.remove(0); + Packet np = (Packet) flowList_.remove(0); boolean ping = false; // a flag to determine ping packet or not int tag = -1; // event tag ID @@ -725,13 +696,13 @@ // send the packet super.sim_schedule(dest, GridSimTags.SCHEDULE_NOW, tag, np); - /***** // DEBUG info **/ + /***** // DEBUG info ** System.out.println(super.get_name() + " send to " + GridSim.getEntityName(dest) + " tag = " + tag + " time " + GridSim.clock()); /****/ // if the list is not empty, then schedule the next packet in the list - if (packetList_.isEmpty() != true) + if (flowList_.isEmpty() != true) { //double delay = np.getSize() * SIZE / link_.getBaudRate(); double delay = 0.0; Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-03-14 01:06:34 UTC (rev 159) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-03-14 06:26:19 UTC (rev 160) @@ -22,7 +22,7 @@ * Structure of a packet used to encapsulate flow passing through the network. * * @invariant $none - * @since GridSim Toolkit 4.0 + * @since GridSim Toolkit 5.0 * @author James Broberg */ public class FlowPacket implements Packet @@ -63,7 +63,7 @@ /** * Constructs a network flow for data that fits into a single network - * packet. + * flow packet. * * @param data The data to be encapsulated. * @param pktID The ID of this packet @@ -101,7 +101,7 @@ } /** - * This is used to construct a packet that is one in a series. This happens + * This is used to construct a flow that is one in a series. This happens * when a large piece of data is required to be brokwn down into smaller * chunks so that they can traverse of links that only support a certain * MTU. It also allows setting of a classtype so that network schedulers @@ -149,8 +149,8 @@ } /** - * Returns a description of this packet - * @return a description of this packet + * Returns a description of this flow + * @return a description of this flow * @pre $none * @post $none */ @@ -177,8 +177,8 @@ sb.append("GridSimTags.JUNK_PKT"); } else if (tag == GridSimTags.FLOW_SUBMIT) { sb.append("GridSimTags.FLOW_SUBMIT"); -// } else if (tag == GridSimTags.FLOW_RETURN) { -// sb.append("GridSimTags.FLOW_RETURN"); + } else if (tag == GridSimTags.FLOW_ACK) { + sb.append("GridSimTags.FLOW_ACK"); } else { sb.append(tag); } @@ -190,7 +190,7 @@ } /** - * Returns the data encapsulated in this NetPacket + * Returns the data encapsulated in this FlowPacket * @return data encapsulated in this packet * @pre $none * @post $none @@ -201,7 +201,7 @@ /** * Returns the source ID of this packet. The source ID is where the - * NetPacket was originally created. + * FlowPacket was originally created. * * @return the source id. * @pre $none @@ -222,7 +222,7 @@ } /** - * Modifies the data encapsulated in this NetPacket. + * Modifies the data encapsulated in this FlowPacket. * @param data the packet's data * @pre $none * @post $none @@ -232,7 +232,7 @@ } /** - * Gets the size of this packet + * Gets the size of this flow packet * @return the packet size * @pre $none * @post $none @@ -243,7 +243,7 @@ /** * Sets the packet size - * @param size the packet size + * @param size the flow packet size * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise * @pre size >= 0 * @post $none @@ -260,7 +260,7 @@ /** * Returns the tag associated originally with data that was encapsulated in - * this packet. + * this flow packet. * * @return the tag of the data contained. * @pre $none @@ -271,7 +271,7 @@ } /** - * Returns the destination ID of this packet + * Returns the destination ID of this flow packet * * @return destination ID * @pre $none @@ -282,7 +282,7 @@ } /** - * Sets the destination id of this packet + * Sets the destination id of this flow packet * @param id the destination id * @pre id >= 0 * @post $none @@ -292,7 +292,7 @@ } /** - * Sets the last hop that this NetPacket traversed. This is used to + * Sets the last hop that this FlowPacket traversed. This is used to * determine the next hop at routers. Only routers and hosts/GridResources * set this, links do not modify it. * @param last the entity ID from the last hop @@ -304,7 +304,7 @@ } /** - * Returns the ID of the last hop that this packet traversed. This could be + * Returns the ID of the last hop that this flow packet traversed. This could be * the ID of a router, host or GridResource. * * @return ID of the last hop @@ -316,7 +316,7 @@ } /** - * Sets the network class type of this packet, so that it can receive + * Sets the network class type of this flow packet, so that it can receive * differentiated services. * @param netServiceType a network service type * @pre netServiceType >= 0 @@ -327,8 +327,8 @@ } /** - * Returns the class type of this packet. Used by routers etc. to determine - * the level of service that this packet should obtain. + * Returns the class type of this flow packet. Used by routers etc. to determine + * the level of service that this flow packet should obtain. * * @return the class of this packet * @pre $none @@ -339,7 +339,7 @@ } /** - * Returns the serial number of this packet. + * Returns the serial number of this flow packet. * * @return packet number * @pre $none @@ -350,11 +350,11 @@ } /** - * Returns the total number of packets in this stream. A stream of + * Returns the total number of flow packets in this stream. A stream of * packets is sent whenever the data is too big to be sent as one * packet. * - * @return total number of packets in this stream. + * @return total number of flow packets in this stream. * @pre $none * @post $none */ Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java 2008-03-14 01:06:34 UTC (rev 159) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java 2008-03-14 06:26:19 UTC (rev 160) @@ -1,5 +1,5 @@ /* - * ** Network and Service Differentiation Extensions to GridSim 3.0 ** + * ** Network and Service Differentiation Extensions to GridSim 5.0 ** * * Author: James Broberg * @@ -25,7 +25,7 @@ /** - * This class implements a Router using a form of RIP for routing. The routing + * This class implements a FlowRouter using a form of RIP for routing. The routing * protocol used here is similar to <a * href="http://www.ietf.org/rfc/rfc1058.txt">Routing Information Protocol * (RIP) </a>. The routing protocol is run before Gridlets etc. can be @@ -37,7 +37,7 @@ * reliable protocol to use. * * @invariant $none - * @since GridSim Toolkit 3.1 + * @since GridSim Toolkit 5.0 * @author James Broberg, The University of Melbourne * @author Gokul Poduval & Chen-Khong Tham, National University of Singapore */ @@ -289,7 +289,7 @@ case GridSimTags.PKT_FORWARD: case GridSimTags.JUNK_PKT: System.out.println(super.get_name() + ".processEvent(): processNetPacket() + at time = " + GridSim.clock()); - processNetPacket(ev, ev.get_tag()); + processFlowPacket(ev, ev.get_tag()); break; case GridSimTags.ROUTER_AD: @@ -316,7 +316,7 @@ * @pre ev != null * @post $none */ - private synchronized void processNetPacket(Sim_event ev, int tag) + private synchronized void processFlowPacket(Sim_event ev, int tag) { //double nextTime = 0; Packet pkt = (Packet) ev.get_data(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-14 01:14:32
|
Revision: 158 http://gridsim.svn.sourceforge.net/gridsim/?rev=158&view=rev Author: brobergj Date: 2008-03-13 18:05:46 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Bug fixes Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java 2008-03-13 05:39:26 UTC (rev 157) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowInput.java 2008-03-14 01:05:46 UTC (rev 158) @@ -232,6 +232,15 @@ // Send ack to source of flow System.out.println(super.get_name() + ".checkForecast(): flow came from " + GridSim.getEntityName(fp.getSrcID()) + " heading to " + GridSim.getEntityName(fp.getDestID())); + + // Deregister flow on all active links + Iterator it = (fp.getLinks_()).iterator(); + while (it.hasNext()) { + FlowLink fl = (FlowLink) it.next(); + fl.deregisterFlow(fp); + } + + /* int oldDestID = fp.getDestID(); int oldSrcID = fp.getSrcID(); @@ -248,7 +257,7 @@ super.sim_schedule(GridSim.getEntityId("Output_" + GridSim.getEntityName(oldDestID)), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_ACK, fpAck); - //super.sim_schedule(super.get_id(), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_ACK, fpAck); + //super.sim_schedule(super.get_id(), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_ACK, fpAck); */ } else { System.out.println(super.get_name() + ".checkForecast(): pkt id # " + pktID + " already removed"); @@ -280,7 +289,8 @@ if ((fp = (FlowPacket) activeFlows_.get(pktID)) != null) { remSizeOld = fp.getRemSize(); bandwidthOld = fp.getBandwidth_(); - System.out.println(super.get_name() + "updateForecast(): rem size is " + remSizeOld + "BW old is " + bandwidthOld); + System.out.println(super.get_name() + "updateForecast(): rem size is " + remSizeOld + + "BW old is " + bandwidthOld + " last update " + fp.getUpdateTime()); Iterator it = (fp.getLinks_()).iterator(); while (it.hasNext()) { @@ -291,9 +301,9 @@ } } - fp.setRemSize((long)(remSizeOld*BITS - (GridSim.clock()-fp.getUpdateTime())*bandwidthOld)); - duration = fp.getRemSize()/fp.getBandwidth_(); - System.out.println(super.get_name() + " new remaining duration add " + duration); + fp.setRemSize((long)((remSizeOld) - ((GridSim.clock()-fp.getUpdateTime())*(bandwidthOld/BITS)))); + duration = (fp.getRemSize()*BITS)/fp.getBandwidth_(); + System.out.println(super.get_name() + " new forecast end time is " + (GridSim.clock() + duration)); FilterFlow filter = new FilterFlow(fp.getID(), GridSimTags.FLOW_HOLD); cancelledFlow = this.sim_cancel(filter, null); @@ -304,6 +314,7 @@ } System.out.println(super.get_name() + " setting updated forecast for packet #" + fp.getID()); + fp.setUpdateTime(GridSim.clock()); super.sim_schedule(super.get_id(), duration, GridSimTags.FLOW_HOLD , new Integer(fp.getID())); } @@ -423,35 +434,30 @@ if (tag == GridSimTags.EMPTY_PKT && np.getData() == null) { return; } - - // convert the packets into IO_data - Object data = np.getData(); - IO_data io = new IO_data( data, np.getSize(), - inPort_.get_src()); + System.out.println(super.get_name() + ".getDataFromLink() Time now " + GridSim.clock() + " bottleneck is " + np.getBandwidth_() + " sum lat is " + np.getLatency() ); // if flow terminates at next entity, add to active flows // & hold for appropriate duration if (pkt.getTag() == GridSimTags.FLOW_SUBMIT || pkt.getTag() == GridSimTags.GRIDLET_SUBMIT || - pkt.getTag() == GridSimTags.GRIDLET_SUBMIT_ACK || pkt.getTag() == GridSimTags.GRIDLET_RETURN) { + pkt.getTag() == GridSimTags.GRIDLET_SUBMIT_ACK || pkt.getTag() == GridSimTags.GRIDLET_RETURN + || pkt.getTag() == GridSimTags.JUNK_PKT) { np.setStartTime(GridSim.clock()); np.setUpdateTime(GridSim.clock()); duration = np.getSize()*SIZE / np.getBandwidth_(); activeFlows_.put(pkt.getID(), pkt); super.sim_schedule(super.get_id(), duration, GridSimTags.FLOW_HOLD, new Integer(pkt.getID())); - System.out.println(super.get_name() + ".getDataFromLink() forecast flow end at " + (GridSim.clock() + System.out.println(super.get_name() + ".getDataFromLink() initial forecast flow end at " + (GridSim.clock() + duration)); - - // if flow is just an ACK of a finished flow do not hold, no action required - } else if (pkt.getTag() == GridSimTags.FLOW_RETURN){ - //duration = 0.0; - return; - // send the data into entity input/output port - // super.sim_schedule(inPort_, duration, tag, - // io.getData() ); + return; } + // convert the packets into IO_data + Object data = np.getData(); + IO_data io = new IO_data( data, np.getSize(), + inPort_.get_dest() ); + // send the data into entity input port super.sim_schedule(inPort_, GridSimTags.SCHEDULE_NOW, tag, io.getData() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-14 01:14:32
|
Revision: 159 http://gridsim.svn.sourceforge.net/gridsim/?rev=159&view=rev Author: brobergj Date: 2008-03-13 18:06:34 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Bug fixes Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-03-14 01:05:46 UTC (rev 158) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-03-14 01:06:34 UTC (rev 159) @@ -131,13 +131,8 @@ return; } - System.out.println(super.get_name() + ".attach(): " + end1.get_name() + - " " + end2.get_name()); - inEnd1_ = GridSim.getEntityId( "Output_" + end1.get_name() ); + inEnd1_ = GridSim.getEntityId( "Input_" + end1.get_name() ); outEnd1_ = GridSim.getEntityId( "Output_" + end1.get_name() ); - - System.out.println(super.get_name() + ".attach(): " + end1.get_id() + " " + end2.get_id()); - // if end1 is a router/gateway with no Input and Output port if (inEnd1_ == -1 || outEnd1_ == -1) @@ -146,10 +141,10 @@ outEnd1_ = end1.get_id(); } - inEnd2_ = GridSim.getEntityId( "Output_" + end2.get_name() ); + inEnd2_ = GridSim.getEntityId( "Input_" + end2.get_name() ); outEnd2_ = GridSim.getEntityId( "Output_" + end2.get_name() ); - // if end2 is a router/gateway with no Input and Output port + // if end1 is a router/gateway with no Input and Output port if (inEnd2_ == -1 || outEnd2_ == -1) { inEnd2_ = end2.get_id(); @@ -181,7 +176,7 @@ return; } - inEnd1_ = GridSim.getEntityId("Output_" + end1); + inEnd1_ = GridSim.getEntityId("Input_" + end1); outEnd1_ = GridSim.getEntityId("Output_" + end1); // if end1 is a router/gateway with no Input and Output port @@ -191,7 +186,7 @@ outEnd1_ = inEnd1_; } - inEnd2_ = GridSim.getEntityId("Output_" + end2); + inEnd2_ = GridSim.getEntityId("Input_" + end2); outEnd2_ = GridSim.getEntityId("Output_" + end2); // if end1 is a router/gateway with no Input and Output port @@ -218,6 +213,9 @@ while ( Sim_system.running() ) { super.sim_get_next(ev); + + System.out.println(super.get_name() + ".body(): ev.get_tag() is " + ev.get_tag()); + System.out.println(super.get_name() + ".body(): ev.get_src() is " + ev.get_src()); // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { @@ -335,15 +333,20 @@ private synchronized void enque(Sim_event ev) { System.out.println(super.get_name() + " enque() + at time = " + GridSim.clock()); + int tag = ((Packet)ev.get_data()).getTag(); + // Register passing flow as active on this link + if (tag == GridSimTags.FLOW_SUBMIT || tag == GridSimTags.GRIDLET_SUBMIT || + tag == GridSimTags.GRIDLET_SUBMIT_ACK || tag == GridSimTags.GRIDLET_RETURN || + tag == GridSimTags.JUNK_PKT) { + registerFlow((Packet)ev.get_data()); + } + q_.add( ev.get_data() ); if (q_.size() == 1) { sendInternalEvent(super.delay_ / super.MILLI_SEC); // delay in ms } - // Register passing flow as active on this link - if (((Packet)ev.get_data()).getTag() == GridSimTags.FLOW_SUBMIT) { - registerFlow((Packet)ev.get_data()); - } + } /** @@ -354,8 +357,14 @@ */ private synchronized void deque(Packet np) { + + System.out.println(super.get_name() + ".deque() for packet " + np.getID() +" here"); + System.out.println(super.get_name() + ".deque() packet " + np.toString()); + + int dest = getNextHop(np); if (dest == -1) { + System.out.println(super.get_name() + ".deque() here3"); return; } @@ -363,6 +372,8 @@ int tag = 0; if (dest == outEnd2_ || dest == outEnd1_) { + System.out.println(super.get_name() + ".deque() here1"); + // for junk packets only if (np.getTag() == GridSimTags.JUNK_PKT) { tag = GridSimTags.JUNK_PKT; @@ -374,15 +385,17 @@ } // other side is a GridSim entity else { + System.out.println(super.get_name() + ".deque() here2"); + tag = np.getTag(); } - if (np.getTag() == GridSimTags.FLOW_RETURN) { - System.out.println(super.get_name() + ".deque() Dereg flow # " + np.getID() +" here"); + //if (np.getTag() == GridSimTags.FLOW_RETURN) { + // System.out.println(super.get_name() + ".deque() Dereg flow # " + np.getID() +" here"); // Deregister passing flow as it is now de-active on this link - ((FlowPacket)np).addLatency(this.getDelay()); - deregisterFlow(np); - } + // ((FlowPacket)np).addLatency(this.getDelay()); + // deregisterFlow(np); + //} // sends the packet super.sim_schedule(dest, GridSimTags.SCHEDULE_NOW, tag, np); @@ -447,7 +460,7 @@ // I can notify directly as I know the destId's!!!! System.out.println(super.get_name() + ".registerFlow(): updating flow #" + tempFlow.getID() + " destination " + tempFlow.getDestID()); - super.sim_schedule(GridSim.getEntityId("Output_" + + super.sim_schedule(GridSim.getEntityId("Input_" + GridSim.getEntityName(tempFlow.getDestID())), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID())); } @@ -460,7 +473,7 @@ * @pre $none * @post $none */ - private synchronized void deregisterFlow(Packet np) { + public synchronized void deregisterFlow(Packet np) { FlowPacket fp = null; FlowPacket tempFlow; @@ -483,7 +496,7 @@ // I can notify directly as I know the destId's!!!! System.out.println(super.get_name() + ".deregisterFlow(): updating flow #" + tempFlow.getID() + " destination " + tempFlow.getDestID()); - super.sim_schedule(GridSim.getEntityId("Output_" + + super.sim_schedule(GridSim.getEntityId("Input_" + GridSim.getEntityName(tempFlow.getDestID())), GridSimTags.SCHEDULE_NOW, GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID())); } Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java 2008-03-14 01:05:46 UTC (rev 158) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowOutput.java 2008-03-14 01:06:34 UTC (rev 159) @@ -249,7 +249,7 @@ int shutdownID = GridSim.getGridSimShutdownEntityId(); // start generating some junk packets or background traffic - // startBackgroundTraffic(); + startBackgroundTraffic(); // Process incoming events while ( Sim_system.running() ) @@ -288,10 +288,10 @@ break; // activate background traffic - case GridSimTags.FLOW_ACK: - System.out.println((FlowPacket) ev.get_data()); - enque((FlowPacket) ev.get_data(),GridSimTags.SCHEDULE_NOW); - break; + //case GridSimTags.FLOW_ACK: + // System.out.println((FlowPacket) ev.get_data()); + // enque((FlowPacket) ev.get_data(),GridSimTags.SCHEDULE_NOW); + // break; default: defaultSend(ev, gisID, statID, shutdownID); @@ -544,10 +544,10 @@ tag = GridSimTags.EMPTY_PKT; } - np = new FlowPacket(null, pktID_, size, tag, super.get_id(), destId, + np = new FlowPacket(null, rnd.nextInt(10000000), size, tag, super.get_id(), destId, netServiceType, i+1, numPackets); - pktID_++; // increments packet ID + //pktID_++; // increments packet ID enque(np, GridSimTags.SCHEDULE_NOW); } } Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-03-14 01:05:46 UTC (rev 158) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowPacket.java 2008-03-14 01:06:34 UTC (rev 159) @@ -177,8 +177,8 @@ sb.append("GridSimTags.JUNK_PKT"); } else if (tag == GridSimTags.FLOW_SUBMIT) { sb.append("GridSimTags.FLOW_SUBMIT"); - } else if (tag == GridSimTags.FLOW_RETURN) { - sb.append("GridSimTags.FLOW_RETURN"); +// } else if (tag == GridSimTags.FLOW_RETURN) { +// sb.append("GridSimTags.FLOW_RETURN"); } else { sb.append(tag); } Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java 2008-03-14 01:05:46 UTC (rev 158) +++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowRouter.java 2008-03-14 01:06:34 UTC (rev 159) @@ -279,7 +279,9 @@ protected synchronized void processEvent(Sim_event ev) { - System.out.println("Event was scheduled for " + ev.event_time()); + System.out.println(super.get_name() + ".processEvent(): Event was scheduled for " + ev.event_time()); + System.out.println(super.get_name() + ".processEvent(): ev.get_tag() is " + ev.get_tag()); + System.out.println(super.get_name() + ".processEvent(): ev.get_src() is " + ev.get_src()); switch ( ev.get_tag() ) { @@ -611,7 +613,7 @@ GridSimTags.SCHEDULE_NOW, GridSimTags.ROUTER_AD, ad); } - //super.sim_pause(1); // wait for 5 secs to gather the results + super.sim_pause(2); // wait for 5 secs to gather the results } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-13 05:39:23
|
Revision: 157 http://gridsim.svn.sourceforge.net/gridsim/?rev=157&view=rev Author: brobergj Date: 2008-03-12 22:39:26 -0700 (Wed, 12 Mar 2008) Log Message: ----------- Minor updates/fixes from merge Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-03-13 05:32:30 UTC (rev 156) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-03-13 05:39:26 UTC (rev 157) @@ -11,9 +11,7 @@ import eduni.simjava.*; import gridsim.net.*; -import gridsim.net.flow.FlowBuffer; -import gridsim.net.flow.FlowInput; -import gridsim.net.flow.FlowOutput; +import gridsim.net.flow.*; import gridsim.util.*; import java.util.Collection; @@ -317,37 +315,26 @@ { in = new Input("Input_" + name, baudRate); out_ = new Output("Output_" + name, baudRate); - - System.out.println(super.get_name() + ".initNetwork()"); - Sim_system.link_ports(name, "input", "Input_" + name, "input_buffer"); - Sim_system.link_ports(name, "output", "Output_"+name, "output_buffer"); - if (link != null) - { - in.addLink(link); - out_.addLink(link); - } } // Flow Level networking has flow input & output else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { - in = new FlowInput("Input_" + name, baudRate); - out_ = new FlowOutput("Output_" + name, baudRate); - - System.out.println(super.get_name() + ".initNetwork()"); - Sim_system.link_ports(name, "output", "Output_"+name, "output_buffer"); - if (link != null) - { - in.addLink(link); - - out_.addLink(link); - } - + out_ = new FlowOutput("Output_" + name, baudRate); } else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_BUFFER_PACKET_LEVEL) { // TODO: } + + System.out.println(super.get_name() + ".initNetwork()"); + Sim_system.link_ports(name, "input", "Input_" + name, "input_buffer"); + Sim_system.link_ports(name, "output", "Output_" + name, "output_buffer"); + if (link != null) + { + in.addLink(link); + out_.addLink(link); + } } @@ -688,7 +675,7 @@ protected void terminateIOEntities() { // If it is Networked entity and Not yet terminated, then terminate. - if ( isNetworked() && !terminateIOEntitiesFlag_ && NETWORK_TYPE == GridSimTags.NET_PACKET_LEVEL) + if ( isNetworked() && !terminateIOEntitiesFlag_ ) { // Send END_OF_SIMULATION to Input entity send(input, 0.0, GridSimTags.END_OF_SIMULATION); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-13 05:32:30
|
Revision: 156 http://gridsim.svn.sourceforge.net/gridsim/?rev=156&view=rev Author: brobergj Date: 2008-03-12 22:32:30 -0700 (Wed, 12 Mar 2008) Log Message: ----------- Returned back to FlowInput / FlowOutput approach, reinstated support Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-03-13 05:15:21 UTC (rev 155) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-03-13 05:32:30 UTC (rev 156) @@ -12,6 +12,8 @@ import eduni.simjava.*; import gridsim.net.*; import gridsim.net.flow.FlowBuffer; +import gridsim.net.flow.FlowInput; +import gridsim.net.flow.FlowOutput; import gridsim.util.*; import java.util.Collection; @@ -325,16 +327,19 @@ out_.addLink(link); } } - // Flow Level networking has a buffer that handles both input/output + // Flow Level networking has flow input & output else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { - - out_ = new FlowBuffer("Output_" + name, baudRate); - + + in = new FlowInput("Input_" + name, baudRate); + out_ = new FlowOutput("Output_" + name, baudRate); + System.out.println(super.get_name() + ".initNetwork()"); Sim_system.link_ports(name, "output", "Output_"+name, "output_buffer"); if (link != null) { + in.addLink(link); + out_.addLink(link); } @@ -692,10 +697,6 @@ send(output, 0.0, GridSimTags.END_OF_SIMULATION); terminateIOEntitiesFlag_ = true; - // If we are using flow level networking, only terminate output as input is null! - } else if ( isNetworked() && !terminateIOEntitiesFlag_ && NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { - // Send END_OF_SIMULATION to Output entity - send(output, 0.0, GridSimTags.END_OF_SIMULATION); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-13 05:15:18
|
Revision: 155 http://gridsim.svn.sourceforge.net/gridsim/?rev=155&view=rev Author: brobergj Date: 2008-03-12 22:15:21 -0700 (Wed, 12 Mar 2008) Log Message: ----------- Consolidation / tidy up of tags needed by Flow model Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java 2008-03-13 05:10:26 UTC (rev 154) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java 2008-03-13 05:15:21 UTC (rev 155) @@ -31,37 +31,39 @@ // starting constant value for AR-related tags (also negative numbers) private static final int ARBASE = 200; - // TODO: new additions public static final int NET_PACKET_LEVEL = NETBASE + 11; public static final int NET_FLOW_LEVEL = NETBASE + 12; - // Denotes flow en-route to destination - public static final int FLOW_SUBMIT = NETBASE + 13; + // Denotes flow en-route to destination (used manually by entities) + public static final int FLOW_SUBMIT = NETBASE + 13; - // Denotes flow acknowledgement en-route to source - public static final int FLOW_RETURN = NETBASE + 14; - // Internal message to check forecast of flow duration - public static final int FLOW_HOLD = NETBASE + 15; + public static final int FLOW_HOLD = NETBASE + 14; // Message to update forecast of flow duration - public static final int FLOW_UPDATE = NETBASE + 16; + public static final int FLOW_UPDATE = NETBASE + 15; + + // Denotes flow ack en-route to destination (used manually by entities) + public static final int FLOW_ACK = NETBASE + 16; + + // identify a flow as a junk flow used for background traffic + // public static final int JUNK_FLOW = NETBASE + 17; - public static final int NET_BUFFER_PACKET_LEVEL = NETBASE + 17; + public static final int NET_BUFFER_PACKET_LEVEL = NETBASE + 18; // TODO: different flow sharing models - not sure if I will need these // INV-LAT flows are weighted proportionally to the bottleneck latency - // public static final int NET_FLOW_LEVEL_INV_LAT = NETBASE + 15; + // public static final int NET_FLOW_LEVEL_INV_LAT = NETBASE + x; // INV-LAT-BOUND flows are weighted proportionally to the bottleneck latency // with bounded bandwidth availability // INV-RTT flows are weighted proportionally to the bottleneck RTT - // public static final int NET_FLOW_LEVEL_INV_RTT = NETBASE + 16; + // public static final int NET_FLOW_LEVEL_INV_RTT = NETBASE + x; // INV-RTT flows are weighted proportionally to the bottleneck RTT // with bounded bandwidth availability - // public static final int NET_FLOW_LEVEL_INV_RTT_BOUND = NETBASE + 17; + // public static final int NET_FLOW_LEVEL_INV_RTT_BOUND = NETBASE + x; // MAX-MIN flows are equally weighted so all flows get equal share - // public static final int NET_FLOW_LEVEL_MAX_MIN = NETBASE + 18; + // public static final int NET_FLOW_LEVEL_MAX_MIN = NETBASE + x; ////////////////////////////////////////////////////////////////////// @@ -810,6 +812,7 @@ */ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_45_HOURS = -28; + /////////////////////////////////////////////////////////////// /** Private Constructor */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bro...@us...> - 2008-03-13 05:10:19
|
Revision: 154 http://gridsim.svn.sourceforge.net/gridsim/?rev=154&view=rev Author: brobergj Date: 2008-03-12 22:10:26 -0700 (Wed, 12 Mar 2008) Log Message: ----------- FlowNetEx02 is a port of NetEx03 that has been modified to use the Flow networking stack in GridSim. This demonstrates that the flow model works with Gridlets and background traffic. Added Paths: ----------- branches/gridsim4.0-branch2/examples/FlowNetEx02/ branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetEx02.java branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetUser.java branches/gridsim4.0-branch2/examples/FlowNetEx02/NetEx03.class branches/gridsim4.0-branch2/examples/FlowNetEx02/NetUser.class branches/gridsim4.0-branch2/examples/FlowNetEx02/README.txt branches/gridsim4.0-branch2/examples/FlowNetEx02/User_0.csv branches/gridsim4.0-branch2/examples/FlowNetEx02/User_1.csv branches/gridsim4.0-branch2/examples/FlowNetEx02/output.txt branches/gridsim4.0-branch2/examples/FlowNetEx02/router1_report.csv branches/gridsim4.0-branch2/examples/FlowNetEx02/router2_report.csv Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetEx02.java =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetEx02.java (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetEx02.java 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,382 @@ +package FlowNetEx02; +/* + * Author: Anthony Sulistio + * Date: November 2004 + * Description: A simple program to demonstrate of how to use GridSim + * network extension package. + * This example shows how to create user and resource + * entities connected via a network topology, using link + * and router. + * In addition, background traffic functionality is explained + * in this example. + */ + +import gridsim.*; +import gridsim.net.*; +import gridsim.net.flow.FlowLink; +import gridsim.net.flow.FlowRouter; + +import java.util.*; +import gridsim.util.TrafficGenerator; // for background traffic +import eduni.simjava.distributions.*; // for background traffic + + +/** + * Test Driver class for this example + */ +public class FlowNetEx02 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + System.out.println("Starting network example ..."); + + try + { + ////////////////////////////////////////// + // First step: Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + int num_user = 2; // number of grid users + Calendar calendar = Calendar.getInstance(); + + // a flag that denotes whether to trace GridSim events or not. + boolean trace_flag = true; + + // Initialize the GridSim package + System.out.println("Initializing GridSim package"); + GridSim.initNetworkType(GridSimTags.NET_FLOW_LEVEL); + GridSim.init(num_user, calendar, trace_flag); + + + ////////////////////////////////////////// + // Second step: Creates one or more GridResource entities + + double baud_rate = 1000; // bits/sec + double propDelay = 10; // propagation delay in millisecond + int mtu = 1500; // max. transmission unit in byte + int i = 0; + + // more resources can be created by + // setting totalResource to an appropriate value + int totalResource = 1; + ArrayList resList = new ArrayList(totalResource); + for (i = 0; i < totalResource; i++) + { + GridResource res = createGridResource("Res_"+i, baud_rate, + propDelay, mtu); + + // add a resource into a list + resList.add(res); + } + + ////////////////////////////////////////// + // Third step: Creates one or more grid user entities + + // number of Gridlets that will be sent to the resource + int totalGridlet = 5; + + // create users + ArrayList userList = new ArrayList(num_user); + ArrayList userNameList = new ArrayList(); // for background traffic + for (i = 0; i < num_user; i++) + { + String name = "User_" + i; + + // if trace_flag is set to "true", then this experiment will + // create User_i.csv where i = 0 ... (num_user-1) + FlowNetUser user = new FlowNetUser(name, totalGridlet, baud_rate, + propDelay, mtu, trace_flag); + + // add a user into a list + userList.add(user); + userNameList.add(name); + } + + ////////////////////////////////////////// + // Fourth step: Builds the network topology among entities. + + // In this example, the topology is: + // user(s) --1Mb/s-- r1 --10Mb/s-- r2 --1Mb/s-- GridResource(s) + + // create the routers. + // If trace_flag is set to "true", then this experiment will create + // the following files (apart from sim_trace and sim_report): + // - router1_report.csv + // - router2_report.csv + Router r1 = new FlowRouter("router1", trace_flag); // router 1 + Router r2 = new FlowRouter("router2", trace_flag); // router 2 + + // generates some background traffic using SimJava2 distribution + // package. NOTE: if you set the values to be too high, then + // the simulation might finish longer + TrafficGenerator tg = new TrafficGenerator( + new Sim_uniform_obj("freq",1,3), // num of packets + new Sim_uniform_obj("inter_arrival_time",10,20) ); + + // connect all user entities with r1 with 1Mb/s connection + // For each host, specify which PacketScheduler entity to use. + FlowNetUser obj = null; + for (i = 0; i < userList.size(); i++) + { + // A First In First Out Scheduler is being used here. + // SCFQScheduler can be used for more fairness + FIFOScheduler userSched = new FIFOScheduler("NetUserSched_"+i); + obj = (FlowNetUser) userList.get(i); + r1.attachHost(obj, userSched); + + // for even user number + if (i % 2 == 0) + { + // for each time, sends junk packet(s) to all entities + tg.setPattern(TrafficGenerator.SEND_ALL); + + // sends junk packet(s) to resource and user entities + obj.setBackgroundTraffic(tg, userNameList); + } + else // for odd user number + { + // for each time, sends junk packet(s) to only one entity + tg.setPattern(TrafficGenerator.SEND_ONE_ONLY); + + // sends junk packet(s) to resource entities only + obj.setBackgroundTraffic(tg); + } + } + + // connect all resource entities with r2 with 1Mb/s connection + // For each host, specify which PacketScheduler entity to use. + GridResource resObj = null; + for (i = 0; i < resList.size(); i++) + { + FIFOScheduler resSched = new FIFOScheduler("GridResSched_"+i); + resObj = (GridResource) resList.get(i); + r2.attachHost(resObj, resSched); + } + + // then connect r1 to r2 with 10Mb/s connection + // For each host, specify which PacketScheduler entity to use. + baud_rate = 10000; + Link link = new FlowLink("r1_r2_link", baud_rate, propDelay, Integer.MAX_VALUE); + + FIFOScheduler r1Sched = new FIFOScheduler("r1_Sched"); + FIFOScheduler r2Sched = new FIFOScheduler("r2_Sched"); + + // attach r2 to r1 + r1.attachRouter(r2, link, r1Sched, r2Sched); + + ////////////////////////////////////////// + // Fifth step: Starts the simulation + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + + // also prints the routing table + r1.printRoutingTable(); + r2.printRoutingTable(); + + GridletList glList = null; + for (i = 0; i < userList.size(); i++) + { + obj = (FlowNetUser) userList.get(i); + glList = obj.getGridletList(); + printGridletList(glList, obj.get_name(), false); + } + + System.out.println("\nFinish network example ..."); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println("Unwanted errors happen"); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * <p> + * In this simple example, we are simulating one Grid resource with three + * Machines that contains one or more PEs. + * @param name a Grid Resource name + * @param baud_rate the bandwidth of this entity + * @param delay the propagation delay + * @param MTU Maximum Transmission Unit + * @return a GridResource object + */ + private static GridResource createGridResource(String name, + double baud_rate, double delay, int MTU) + { + System.out.println(); + System.out.println("Starting to create one Grid resource with " + + "3 Machines"); + + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + //System.out.println("Creates a Machine list"); + + + // 2. A Machine contains one or more PEs or CPUs. Therefore, should + // create an object of PEList to store these PEs before creating + // a Machine. + PEList peList1 = new PEList(); + //System.out.println("Creates a PE list for the 1st Machine"); + + + // 3. Create PEs and add these into an object of PEList. + // In this example, we are using a resource from + // hpc420.hpcc.jp, AIST, Tokyo, Japan + // Note: these data are taken the from GridSim paper, page 25. + // In this example, all PEs has the same MIPS (Millions + // Instruction Per Second) Rating for a Machine. + peList1.add( new PE(0, 377) ); // need to store PE id and MIPS Rating + peList1.add( new PE(1, 377) ); + peList1.add( new PE(2, 377) ); + peList1.add( new PE(3, 377) ); + //System.out.println("Creates 4 PEs with same MIPS Rating and put them"+ + // " into the PE list"); + + + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(0, peList1) ); // First Machine + //System.out.println("Creates the 1st Machine that has 4 PEs and " + + // "stores it into the Machine list"); + //System.out.println(); + + // 5. Repeat the process from 2 if we want to create more Machines + // In this example, the AIST in Japan has 3 Machines with same + // MIPS Rating but different PEs. + // NOTE: if you only want to create one Machine for one Grid resource, + // then you could skip this step. + PEList peList2 = new PEList(); + //System.out.println("Creates a PE list for the 2nd Machine"); + + peList2.add( new PE(0, 377) ); + peList2.add( new PE(1, 377) ); + peList2.add( new PE(2, 377) ); + peList2.add( new PE(3, 377) ); + //System.out.println("Creates 4 PEs with same MIPS Rating and put them"+ + // " into the PE list"); + + mList.add( new Machine(1, peList2) ); // Second Machine + //System.out.println("Creates the 2nd Machine that has 4 PEs and " + + // "stores it into the Machine list"); + //System.out.println(); + + PEList peList3 = new PEList(); + //System.out.println("Creates a PE list for the 3rd Machine"); + + peList3.add( new PE(0, 377) ); + peList3.add( new PE(1, 377) ); + //System.out.println("Creates 2 PEs with same MIPS Rating and put them"+ + // " into the PE list"); + + mList.add( new Machine(2, peList3) ); // Third Machine + //System.out.println("Creates the 3rd Machine that has 2 PEs and " + + // "stores it into the Machine list"); + //System.out.println(); + + // 6. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 9.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, ResourceCharacteristics.TIME_SHARED, + time_zone, cost); + + //System.out.println("Creates the properties of a Grid resource and " + + // "stores the Machine list"); + + // 7. Finally, we need to create a GridResource object. + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList Weekends = new LinkedList(); + Weekends.add(new Integer(Calendar.SATURDAY)); + Weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList Holidays = new LinkedList(); + GridResource gridRes = null; + try + { + // creates a GridResource with a link + gridRes = new GridResource(name, + new FlowLink(name + "_link", baud_rate, delay, MTU), + seed, resConfig, peakLoad, offPeakLoad, holidayLoad, + Weekends, Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Finally, creates one Grid resource (name: " + name + + " - id: " + gridRes.get_id() + ")"); + System.out.println(); + + return gridRes; + } + + /** + * Prints the Gridlet objects + */ + private static void printGridletList(GridletList list, String name, + boolean detail) + { + int size = list.size(); + Gridlet gridlet = null; + + String indent = " "; + System.out.println(); + System.out.println("============= OUTPUT for " + name + " =========="); + System.out.println("Gridlet ID" + indent + "STATUS" + indent + + "Resource ID" + indent + "Cost"); + + // a loop to print the overall result + int i = 0; + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + System.out.print( gridlet.getGridletStatusString() ); + + System.out.println( indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() ); + } + + if (detail == true) + { + // a loop to print each Gridlet's history + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.println( gridlet.getGridletHistory() ); + + System.out.print("Gridlet #" + gridlet.getGridletID() ); + System.out.println(", length = " + gridlet.getGridletLength() + + ", finished so far = " + + gridlet.getGridletFinishedSoFar() ); + System.out.println("======================================\n"); + } + } + } + +} // end class + Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetUser.java =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetUser.java (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/FlowNetUser.java 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,222 @@ +package FlowNetEx02; +/* + * Author: Anthony Sulistio + * Date: November 2004 + * Description: A simple program to demonstrate of how to use GridSim + * network extension package. + * This example shows how to create user and resource + * entities connected via a network topology, using link + * and router. + * + */ + +import java.util.*; +import gridsim.*; +import gridsim.net.*; +import gridsim.net.flow.FlowLink; +import gridsim.util.SimReport; + + +/** + * This class basically creates Gridlets and submits them to a + * particular GridResources in a network topology. + */ +class FlowNetUser extends GridSim +{ + private int myId_; // my entity ID + private String name_; // my entity name + private GridletList list_; // list of submitted Gridlets + private GridletList receiveList_; // list of received Gridlets + private SimReport report_; // logs every events + + + /** + * Creates a new NetUser object + * @param name this entity name + * @param totalGridlet total number of Gridlets to be created + * @param baud_rate bandwidth of this entity + * @param delay propagation delay + * @param MTU Maximum Transmission Unit + * @param trace_flag logs every event or not + * @throws Exception This happens when name is null or haven't + * initialized GridSim. + */ + FlowNetUser(String name, int totalGridlet, double baud_rate, double delay, + int MTU, boolean trace_flag) throws Exception + { + //super( name, new FlowLink(name+"_link",baud_rate,delay, MTU) ); + super(name, new FlowLink(name+"_link",baud_rate,delay,Integer.MAX_VALUE)); + + + this.name_ = name; + this.receiveList_ = new GridletList(); + this.list_ = new GridletList(); + + // creates a report file + if (trace_flag == true) { + report_ = new SimReport(name); + } + + // Gets an ID for this entity + this.myId_ = super.getEntityId(name); + write("Creating a grid user entity with name = " + + name + ", and id = " + this.myId_); + + // Creates a list of Gridlets or Tasks for this grid user + write(name + ":Creating " + totalGridlet +" Gridlets"); + this.createGridlet(myId_, totalGridlet); + } + + /** + * The core method that handles communications among GridSim entities. + */ + public void body() + { + // wait for a little while for about 3 seconds. + // This to give a time for GridResource entities to register their + // services to GIS (GridInformationService) entity. + super.gridSimHold(3.0); + LinkedList resList = super.getGridResourceList(); + + // initialises all the containers + int totalResource = resList.size(); + int resourceID[] = new int[totalResource]; + String resourceName[] = new String[totalResource]; + + // a loop to get all the resources available + int i = 0; + for (i = 0; i < totalResource; i++) + { + // Resource list contains list of resource IDs + resourceID[i] = ( (Integer) resList.get(i) ).intValue(); + + // get their names as well + resourceName[i] = GridSim.getEntityName( resourceID[i] ); + } + + //////////////////////////////////////////////// + // SUBMIT Gridlets + + // determines which GridResource to send to + int index = myId_ % totalResource; + if (index >= totalResource) { + index = 0; + } + + // sends all the Gridlets + Gridlet gl = null; + boolean success; + for (i = 0; i < list_.size(); i++) + { + gl = (Gridlet) list_.get(i); + write(name_ + "Sending Gridlet #" + i + " to " + resourceName[index]); + + // For even number of Gridlets, send without an acknowledgement + // whether a resource has received them or not. + if (i % 2 == 0) + { + // by default - send without an ack + success = super.gridletSubmit(gl, resourceID[index]); + } + + // For odd number of Gridlets, send with an acknowledgement + else + { + // this is a blocking call + success = super.gridletSubmit(gl,resourceID[index],0.0,true); + write("ack = " + success + " for Gridlet #" + i); + } + } + + //////////////////////////////////////////////////////// + // RECEIVES Gridlets back + + // hold for few period - few seconds since the Gridlets length are + // quite huge for a small bandwidth + super.gridSimHold(5); + + // receives the gridlet back + for (i = 0; i < list_.size(); i++) + { + gl = (Gridlet) super.receiveEventObject(); // gets the Gridlet + receiveList_.add(gl); // add into the received list + + write(name_ + ": Receiving Gridlet #" + + gl.getGridletID() + " at time = " + GridSim.clock() ); + } + + //////////////////////////////////////////////////////// + // ping functionality + InfoPacket pkt = null; + int size = 500; + + // There are 2 ways to ping an entity: + // a. non-blocking call, i.e. + //super.ping(resourceID[index], size); // (i) ping + //super.gridSimHold(10); // (ii) do something else + //pkt = super.getPingResult(); // (iii) get the result back + + // b. blocking call, i.e. ping and wait for a result + pkt = super.pingBlockingCall(resourceID[index], size); + + // print the result + write("\n-------- " + name_ + " ----------------"); + write(pkt.toString()); + write("-------- " + name_ + " ----------------\n"); + + //////////////////////////////////////////////////////// + // shut down I/O ports + shutdownUserEntity(); + terminateIOEntities(); + + // don't forget to close the file + if (report_ != null) { + report_.finalWrite(); + } + + write(this.name_ + ": sending and receiving of Gridlets" + + " complete at " + GridSim.clock() ); + } + + /** + * Gets a list of received Gridlets + * @return a list of received/completed Gridlets + */ + public GridletList getGridletList() { + return receiveList_; + } + + /** + * This method will show you how to create Gridlets + * @param userID owner ID of a Gridlet + * @param numGridlet number of Gridlet to be created + */ + private void createGridlet(int userID, int numGridlet) + { + int data = 5000; + for (int i = 0; i < numGridlet; i++) + { + // Creates a Gridlet + Gridlet gl = new Gridlet(i, data, data, data); + gl.setUserID(userID); + + // add this gridlet into a list + this.list_.add(gl); + } + } + + /** + * Prints out the given message into stdout. + * In addition, writes it into a file. + * @param msg a message + */ + private void write(String msg) + { + System.out.println(msg); + if (report_ != null) { + report_.write(msg); + } + } + +} // end class + Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/NetEx03.class =================================================================== (Binary files differ) Property changes on: branches/gridsim4.0-branch2/examples/FlowNetEx02/NetEx03.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/NetUser.class =================================================================== (Binary files differ) Property changes on: branches/gridsim4.0-branch2/examples/FlowNetEx02/NetUser.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/README.txt =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/README.txt (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/README.txt 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,53 @@ + +/** + * Author: James Broberg (adapted from NetEx03) + * Date: March 2008 + */ + + +Welcome to the Example of how to use GridSim network extension. +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. FlowNetEx02.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. FlowNetEx02.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: + In Unix/Linux: java -classpath $GRIDSIM/jars/gridsim.jar:. FlowNetEx02 > file.txt + In Windows: java -classpath %GRIDSIM%\jars\gridsim.jar;. FlowNetEx02 > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, I renamed "file.txt" into +"output.txt" +NOTE: When you open "output.txt" file, it tells you that grid user entities + sending Gridlets to a selected grid resource. + + +When running the example file, it will produce the following files: + + tracefile -> created by SimJava 1.2, now being replaced by sim_trace. + NOTE: GridSim 2.1 uses SimJava 1.2 + GridSim 2.2 onwards use SimJava2 + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + *.csv -> created by NetUser.java and gridsim.net.RIPRouter.java + to record every incoming activities. + The format of this file is: + simulation_time, ... + + where ... means other descriptive information. + +NOTE: sim_trace, sim_report and all *.csv files will be overwritten if running + a new experiment. Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/User_0.csv =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/User_0.csv (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/User_0.csv 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,32 @@ +0.0, Creating a grid user entity with name = User_0, and id = 10 +0.0, User_0:Creating 5 Gridlets +3.0, User_0Sending Gridlet #0 to Res_0 +3.0, User_0Sending Gridlet #1 to Res_0 +205.59299946949602, ack = true for Gridlet #1 +205.59299946949602, User_0Sending Gridlet #2 to Res_0 +205.59299946949602, User_0Sending Gridlet #3 to Res_0 +786.6569994694959, ack = true for Gridlet #3 +786.6569994694959, User_0Sending Gridlet #4 to Res_0 +791.6569994694959, User_0: Receiving Gridlet #0 at time = 791.6569994694959 +791.6569994694959, User_0: Receiving Gridlet #1 at time = 791.6569994694959 +791.6569994694959, User_0: Receiving Gridlet #2 at time = 791.6569994694959 +875.8505994694959, User_0: Receiving Gridlet #3 at time = 875.8505994694959 +2487.722599469497, User_0: Receiving Gridlet #4 at time = 2487.722599469497 +6280.660000000001, +-------- User_0 ---------------- +6280.660000000001, Ping information for User_0 +Entity Name Entry Time Exit Time Bandwidth +---------------------------------------------------------- +User_0 2487.7226 3995.000 1000.000 +router1 3995.010 3997.410 10000.000 +router2 3997.420 6272.220 1000.000 +Res_0 6272.230 6276.230 1000.000 +router2 6276.240 6276.640 10000.000 +router1 6276.650 6280.650 1000.000 +User_0 6280.660 N/A N/A + +Round Trip Time : 2285.660 seconds +Number of Hops : 3 +Bottleneck Bandwidth : 1000.0 bits/s +6280.660000000001, -------- User_0 ---------------- + Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/User_1.csv =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/User_1.csv (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/User_1.csv 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,32 @@ +0.0, Creating a grid user entity with name = User_1, and id = 14 +0.0, User_1:Creating 5 Gridlets +3.0, User_1Sending Gridlet #0 to Res_0 +3.0, User_1Sending Gridlet #1 to Res_0 +219.01999999999998, ack = true for Gridlet #1 +219.01999999999998, User_1Sending Gridlet #2 to Res_0 +219.01999999999998, User_1Sending Gridlet #3 to Res_0 +835.722599469496, ack = true for Gridlet #3 +835.722599469496, User_1Sending Gridlet #4 to Res_0 +840.722599469496, User_1: Receiving Gridlet #0 at time = 840.722599469496 +840.722599469496, User_1: Receiving Gridlet #1 at time = 840.722599469496 +840.722599469496, User_1: Receiving Gridlet #2 at time = 840.722599469496 +883.786599469496, User_1: Receiving Gridlet #3 at time = 883.786599469496 +2543.0200000000004, User_1: Receiving Gridlet #4 at time = 2543.0200000000004 +6680.660000000001, +-------- User_1 ---------------- +6680.660000000001, Ping information for User_1 +Entity Name Entry Time Exit Time Bandwidth +---------------------------------------------------------- +User_1 2543.020 4283.000 1000.000 +router1 4283.010 4283.410 10000.000 +router2 4283.420 6672.220 1000.000 +Res_0 6672.230 6676.230 1000.000 +router2 6676.240 6676.640 10000.000 +router1 6676.650 6680.650 1000.000 +User_1 6680.660 N/A N/A + +Round Trip Time : 2397.660 seconds +Number of Hops : 3 +Bottleneck Bandwidth : 1000.0 bits/s +6680.660000000001, -------- User_1 ---------------- + Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/output.txt =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/output.txt (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/output.txt 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,116 @@ +Starting network example ... +Initializing GridSim package +Initialising... + +Starting to create one Grid resource with 3 Machines +Finally, creates one Grid resource (name: Res_0 - id: 5) + +Creating a grid user entity with name = User_0, and id = 10 +User_0:Creating 5 Gridlets +Creating a grid user entity with name = User_1, and id = 14 +User_1:Creating 5 Gridlets +Output_User_0.setBackgroundTraffic(): Warning - can not send junk packets to itself. +Starting GridSim version 3.1 +Entities started. +Output_User_1: background traffic will start at time 14 +Output_User_0: background traffic will start at time 18 +User_1Sending Gridlet #0 to Res_0 +User_0Sending Gridlet #0 to Res_0 +User_1Sending Gridlet #1 to Res_0 +User_0Sending Gridlet #1 to Res_0 +ack = true for Gridlet #1 +User_0Sending Gridlet #2 to Res_0 +User_0Sending Gridlet #3 to Res_0 +ack = true for Gridlet #1 +User_1Sending Gridlet #2 to Res_0 +User_1Sending Gridlet #3 to Res_0 +ack = true for Gridlet #3 +User_0Sending Gridlet #4 to Res_0 +User_0: Receiving Gridlet #0 at time = 821.3943999999999 +User_0: Receiving Gridlet #1 at time = 821.3943999999999 +User_0: Receiving Gridlet #2 at time = 821.3943999999999 +User_0: Receiving Gridlet #3 at time = 891.722599469496 +ack = true for Gridlet #3 +User_1Sending Gridlet #4 to Res_0 +User_1: Receiving Gridlet #0 at time = 1000.02 +User_1: Receiving Gridlet #1 at time = 1000.02 +User_1: Receiving Gridlet #2 at time = 1000.02 +User_1: Receiving Gridlet #3 at time = 1067.084 +User_0: Receiving Gridlet #4 at time = 2367.722599469497 +User_1: Receiving Gridlet #4 at time = 2735.0200000000004 + +-------- User_0 ---------------- +Ping information for User_0 +Entity Name Entry Time Exit Time Bandwidth +---------------------------------------------------------- +User_0 2367.7226 3875.000 1000.000 +router1 3875.010 3877.410 10000.000 +router2 3877.420 5720.220 1000.000 +Res_0 5720.230 5724.230 1000.000 +router2 5724.240 5724.640 10000.000 +router1 5724.650 5728.650 1000.000 +User_0 5728.660 N/A N/A + +Round Trip Time : 1853.660 seconds +Number of Hops : 3 +Bottleneck Bandwidth : 1000.0 bits/s +-------- User_0 ---------------- + +User_0: sending and receiving of Gridlets complete at 5728.660000000001 + +-------- User_1 ---------------- +Ping information for User_1 +Entity Name Entry Time Exit Time Bandwidth +---------------------------------------------------------- +User_1 2735.020 4607.000 1000.000 +router1 4607.010 4607.410 10000.000 +router2 4607.420 6852.220 1000.000 +Res_0 6852.230 6856.230 1000.000 +router2 6856.240 6856.640 10000.000 +router1 6856.650 6860.650 1000.000 +User_1 6860.660 N/A N/A + +Round Trip Time : 2253.660 seconds +Number of Hops : 3 +Bottleneck Bandwidth : 1000.0 bits/s +-------- User_1 ---------------- + +User_1: sending and receiving of Gridlets complete at 6860.660000000001 +GridInformationService: Notify all GridSim entities for shutting down +Sim_system: No more future events +Gathering simulation data. +Simulation completed. + +--- Routing Table for router1 --- +router2 r1_r2_link +User_1 User_1_link +User_0 User_0_link +Res_0 router2 +------------------------------------- + + +--- Routing Table for router2 --- +Res_0 Res_0_link +router1 r1_r2_link +User_0 router1 +User_1 router1 +------------------------------------- + + +============= OUTPUT for User_0 ========== +Gridlet ID STATUS Resource ID Cost + 0 Success 5 39.78779840848807 + 1 Success 5 39.78779840848807 + 2 Success 5 42.7877984084879 + 3 Success 5 42.7877984084879 + 4 Success 5 42.78779840848756 + +============= OUTPUT for User_1 ========== +Gridlet ID STATUS Resource ID Cost + 0 Success 5 39.78779840848807 + 1 Success 5 39.78779840848807 + 2 Success 5 42.7877984084879 + 3 Success 5 42.7877984084879 + 4 Success 5 42.78779840848756 + +Finish network example ... Added: branches/gridsim4.0-branch2/examples/FlowNetEx02/router1_report.csv =================================================================== --- branches/gridsim4.0-branch2/examples/FlowNetEx02/router1_report.csv (rev 0) +++ branches/gridsim4.0-branch2/examples/FlowNetEx02/router1_report.csv 2008-03-13 05:10:26 UTC (rev 154) @@ -0,0 +1,5792 @@ +0.0, attach this ROUTER, to entity, User_0, with packet scheduler, NetUserSched_0 +0.0, attach this ROUTER, to entity, User_1, with packet scheduler, NetUserSched_1 +0.0, attach this ROUTER, with router, router2, with link, r1_r2_link, with packet scheduler, r1_Sched +0.0, register this entity to GridInformationService entity. +0.0, advertise to router, router2 +5.0, receive router ad from, router2 +15.01, +15.01, receive incoming, Packet #1, out of, 4, with id, 0, from, Output_User_0, to, Res_0, tag, 21, delay, 1.2 +15.01, break this packet into, 1 +15.01, enqueing, Packet #1, out of, 4, with id, 0, from, Output_User_0, to, Res_0, tag, 21 +15.01, +15.01, receive incoming, Packet #1, out of, 4, with id, 0, from, Output_User_1, to, Res_0, tag, 21, delay, 0.0 +15.01, break this packet into, 1 +15.01, enqueing, Packet #1, out of, 4, with id, 0, from, Output_User_1, to, Res_0, tag, 21 +16.21, dequeuing, Packet #1, out of, 4, with id, 0, from, Output_User_0, to, Res_0, tag, 21 +17.41, dequeuing, Packet #1, out of, 4, with id, 0, from, Output_User_1, to, Res_0, tag, 21 +27.01, +27.01, receive incoming, Packet #2, out of, 4, with id, 1, from, Output_User_0, to, Res_0, tag, 21, delay, 1.2 +27.01, break this packet into, 1 +27.01, enqueing, Packet #2, out of, 4, with id, 1, from, Output_User_0, to, Res_0, tag, 21 +27.01, +27.01, receive incoming, Packet #2, out of, 4, with id, 1, from, Output_User_1, to, Res_0, tag, 21, delay, 0.0 +27.01, break this packet into, 1 +27.01, enqueing, Packet #2, out of, 4, with id, 1, from, Output_User_1, to, Res_0, tag, 21 +28.21, dequeuing, Packet #2, out of, 4, with id, 1, from, Output_User_0, to, Res_0, tag, 21 +29.41, dequeuing, Packet #2, out of, 4, with id, 1, from, Output_User_1, to, Res_0, tag, 21 +39.01, +39.01, receive incoming, Packet #3, out of, 4, with id, 2, from, Output_User_0, to, Res_0, tag, 21, delay, 1.2 +39.01, break this packet into, 1 +39.01, enqueing, Packet #3, out of, 4, with id, 2, from, Output_User_0, to, Res_0, tag, 21 +39.01, +39.01, receive incoming, Packet #3, out of, 4, with id, 2, from, Output_User_1, to, Res_0, tag, 21, delay, 0.0 +39.01, break this packet into, 1 +39.01, enqueing, Packet #3, out of, 4, with id, 2, from, Output_User_1, to, Res_0, tag, 21 +40.21, dequeuing, Packet #3, out of, 4, with id, 2, from, Output_User_0, to, Res_0, tag, 21 +41.410000000000004, dequeuing, Packet #3, out of, 4, with id, 2, from, Output_User_1, to, Res_0, tag, 21 +51.01, +51.01, receive incoming, Packet #4, out of, 4, with id, 3, from, Output_User_0, to, Res_0, tag, 21, delay, 0.4 +51.01, break this packet into, 1 +51.01, enqueing, Packet #4, out of, 4, with id, 3, from, Output_User_0, to, Res_0, tag, 21 +51.01, +51.01, receive incoming, Packet #4, out of, 4, with id, 3, from, Output_User_1, to, Res_0, tag, 21, delay, 0.0 +51.01, break this packet into, 1 +51.01, enqueing, Packet #4, out of, 4, with id, 3, from, Output_User_1, to, Res_0, tag, 21 +51.41, dequeuing, Packet #4, out of, 4, with id, 3, from, Output_User_0, to, Res_0, tag, 21 +51.809999999999995, dequeuing, Packet #4, out of, 4, with id, 3, from, Output_User_1, to, Res_0, tag, 21 +55.01, +55.01, receive incoming, Packet #1, out of, 4, with id, 4, from, Output_User_1, to, Res_0, tag, 22, delay, 1.2 +55.01, break this packet into, 1 +55.01, enqueing, Packet #1, out of, 4, with id, 4, from, Output_User_1, to, Res_0, tag, 22 +55.01, +55.01, receive incoming, Packet #1, out of, 4, with id, 4, from, Output_User_0, to, Res_0, tag, 22, delay, 0.0 +55.01, break this packet into, 1 +55.01, enqueing, Packet #1, out of, 4, with id, 4, from, Output_User_0, to, Res_0, tag, 22 +56.21, dequeuing, Packet #1, out of, 4, with id, 4, from, Output_User_1, to, Res_0, tag, 22 +57.410000000000004, dequeuing, Packet #1, out of, 4, with id, 4, from, Output_User_0, to, Res_0, tag, 22 +67.01, +67.01, receive incoming, Packet #2, out of, 4, with id, 5, from, Output_User_0, to, Res_0, tag, 22, delay, 1.2 +67.01, break this packet into, 1 +67.01, enqueing, Packet #2, out of, 4, with id, 5, from, Output_User_0, to, Res_0, tag, 22 +67.01, +67.01, receive incoming, Packet #2, out of, 4, with id, 5, from, Output_User_1, to, Res_0, tag, 22, delay, 0.0 +67.01, break this packet into, 1 +67.01, enqueing, Packet #2, out of, 4, with id, 5, from, Output_User_1, to, Res_0, tag, 22 +68.21000000000001, dequeuing, Packet #2, out of, 4, with id, 5, from, Output_User_0, to, Res_0, tag, 22 +69.41000000000001, dequeuing, Packet #2, out of, 4, with id, 5, from, Output_User_1, to, Res_0, tag, 22 +79.01, +79.01, receive incoming, Packet #3, out of, 4, with id, 6, from, Output_User_1, to, Res_0, tag, 22, delay, 1.2 +79.01, break this packet into, 1 +79.01, enqueing, Packet #3, out of, 4, with id, 6, from, Output_User_1, to, Res_0, tag, 22 +79.01, +79.01, receive incoming, Packet #3, out of, 4, with id, 6, from, Output_User_0, to, Res_0, tag, 22, delay, 0.0 +79.01, break this packet into, 1 +79.01, enqueing, Packet #3, out of, 4, with id, 6, from, Output_User_0, to, Res_0, tag, 22 +80.21000000000001, dequeuing, Packet #3, out of, 4, with id, 6, from, Output_User_1, to, Res_0, tag, 22 +81.41000000000001, dequeuing, Packet #3, out of, 4, with id, 6, from, Output_User_0, to, Res_0, tag, 22 +91.01, +91.01, receive incoming, Packet #4, out of, 4, with id, 7, from, Output_User_0, to, Res_0, tag, 22, delay, 0.4 +91.01, break this packet into, 1 +91.01, enqueing, Packet #4, out of, 4, with id, 7, from, Output_User_0, to, Res_0, tag, 22 +91.01, +91.01, receive incoming, Packet #4, out of, 4, with id, 7, from, Output_User_1, to, Res_0, tag, 22, delay, 0.0 +91.01, break this packet into, 1 +91.01, enqueing, Packet #4, out of, 4, with id, 7, from, Output_User_1, to, Res_0, tag, 22 +91.41000000000001, dequeuing, Packet #4, out of, 4, with id, 7, from, Output_User_0, to, Res_0, tag, 22 +91.81000000000002, dequeuing, Packet #4, out of, 4, with id, 7, from, Output_User_1, to, Res_0, tag, 22 +95.01, +95.01, receive incoming, Packet #1, out of, 2, with id, 8, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +95.01, break this packet into, 1 +95.01, enqueing, Packet #1, out of, 2, with id, 8, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +95.01, +95.01, receive incoming, Packet #1, out of, 2, with id, 8, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +95.01, break this packet into, 1 +95.01, enqueing, Packet #1, out of, 2, with id, 8, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +96.21000000000001, dequeuing, Packet #1, out of, 2, with id, 8, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +97.41000000000001, dequeuing, Packet #1, out of, 2, with id, 8, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +107.01, +107.01, receive incoming, Packet #1, out of, 2, with id, 9, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +107.01, break this packet into, 1 +107.01, enqueing, Packet #1, out of, 2, with id, 9, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +107.01, +107.01, receive incoming, Packet #1, out of, 2, with id, 9, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +107.01, break this packet into, 1 +107.01, enqueing, Packet #1, out of, 2, with id, 9, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +108.21000000000001, dequeuing, Packet #1, out of, 2, with id, 9, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +109.41000000000001, dequeuing, Packet #1, out of, 2, with id, 9, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +119.01, +119.01, receive incoming, Packet #1, out of, 2, with id, 10, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +119.01, break this packet into, 1 +119.01, enqueing, Packet #1, out of, 2, with id, 10, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +119.01, +119.01, receive incoming, Packet #1, out of, 2, with id, 10, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +119.01, break this packet into, 1 +119.01, enqueing, Packet #1, out of, 2, with id, 10, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +120.21000000000001, dequeuing, Packet #1, out of, 2, with id, 10, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +121.41000000000001, dequeuing, Packet #1, out of, 2, with id, 10, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +126.71259946949604, +126.71259946949604, receive incoming, Packet #1, out of, 4, with id, 0, from, Output_Res_0, to, User_0, tag, 20, delay, 12.0 +126.71259946949604, break this packet into, 1 +126.71259946949604, enqueing, Packet #1, out of, 4, with id, 0, from, Output_Res_0, to, User_0, tag, 20 +131.01, +131.01, receive incoming, Packet #1, out of, 2, with id, 11, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 12.0 +131.01, break this packet into, 1 +131.01, enqueing, Packet #1, out of, 2, with id, 11, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +131.01, +131.01, receive incoming, Packet #1, out of, 2, with id, 11, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +131.01, break this packet into, 1 +131.01, enqueing, Packet #1, out of, 2, with id, 11, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +132.20999999999998, dequeuing, Packet #1, out of, 2, with id, 11, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +138.712599469496, +138.712599469496, receive incoming, Packet #2, out of, 4, with id, 1, from, Output_Res_0, to, User_0, tag, 20, delay, 0.0 +138.712599469496, break this packet into, 1 +138.712599469496, enqueing, Packet #2, out of, 4, with id, 1, from, Output_Res_0, to, User_0, tag, 20 +138.71259946949604, dequeuing, Packet #1, out of, 4, with id, 0, from, Output_Res_0, to, User_0, tag, 20 +143.01, dequeuing, Packet #1, out of, 2, with id, 11, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +143.01, +143.01, receive incoming, Packet #1, out of, 2, with id, 12, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 12.0 +143.01, break this packet into, 1 +143.01, enqueing, Packet #1, out of, 2, with id, 12, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +143.01, +143.01, receive incoming, Packet #1, out of, 2, with id, 12, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +143.01, break this packet into, 1 +143.01, enqueing, Packet #1, out of, 2, with id, 12, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +144.20999999999998, dequeuing, Packet #1, out of, 2, with id, 12, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +150.712599469496, +150.712599469496, receive incoming, Packet #3, out of, 4, with id, 2, from, Output_Res_0, to, User_0, tag, 20, delay, 0.0 +150.712599469496, break this packet into, 1 +150.712599469496, enqueing, Packet #3, out of, 4, with id, 2, from, Output_Res_0, to, User_0, tag, 20 +150.71259946949604, dequeuing, Packet #2, out of, 4, with id, 1, from, Output_Res_0, to, User_0, tag, 20 +155.01, dequeuing, Packet #1, out of, 2, with id, 12, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +155.01, +155.01, receive incoming, Packet #1, out of, 2, with id, 13, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 12.0 +155.01, break this packet into, 1 +155.01, enqueing, Packet #1, out of, 2, with id, 13, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +155.01, +155.01, receive incoming, Packet #1, out of, 2, with id, 13, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +155.01, break this packet into, 1 +155.01, enqueing, Packet #1, out of, 2, with id, 13, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +156.20999999999998, dequeuing, Packet #1, out of, 2, with id, 13, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +161.91259946949603, +161.91259946949603, receive incoming, Packet #4, out of, 4, with id, 3, from, Output_Res_0, to, User_0, tag, 20, delay, 0.0 +161.91259946949603, break this packet into, 1 +161.91259946949603, enqueing, Packet #4, out of, 4, with id, 3, from, Output_Res_0, to, User_0, tag, 20 +162.71259946949604, dequeuing, Packet #3, out of, 4, with id, 2, from, Output_Res_0, to, User_0, tag, 20 +166.712599469496, +166.712599469496, receive incoming, Packet #1, out of, 4, with id, 4, from, Output_Res_0, to, User_1, tag, 20, delay, 0.0 +166.712599469496, break this packet into, 1 +166.712599469496, enqueing, Packet #1, out of, 4, with id, 4, from, Output_Res_0, to, User_1, tag, 20 +167.01, dequeuing, Packet #1, out of, 2, with id, 13, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +167.01, +167.01, receive incoming, Packet #1, out of, 2, with id, 14, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +167.01, break this packet into, 1 +167.01, enqueing, Packet #1, out of, 2, with id, 14, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +167.01, +167.01, receive incoming, Packet #1, out of, 2, with id, 14, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +167.01, break this packet into, 1 +167.01, enqueing, Packet #1, out of, 2, with id, 14, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +168.20999999999998, dequeuing, Packet #1, out of, 2, with id, 14, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +169.40999999999997, dequeuing, Packet #1, out of, 2, with id, 14, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +174.71259946949604, dequeuing, Packet #4, out of, 4, with id, 3, from, Output_Res_0, to, User_0, tag, 20 +178.712599469496, +178.712599469496, receive incoming, Packet #2, out of, 4, with id, 5, from, Output_Res_0, to, User_1, tag, 20, delay, 0.0 +178.712599469496, break this packet into, 1 +178.712599469496, enqueing, Packet #2, out of, 4, with id, 5, from, Output_Res_0, to, User_1, tag, 20 +179.01, dequeuing, Packet #1, out of, 4, with id, 4, from, Output_Res_0, to, User_1, tag, 20 +179.01, +179.01, receive incoming, Packet #1, out of, 2, with id, 15, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +179.01, break this packet into, 1 +179.01, enqueing, Packet #1, out of, 2, with id, 15, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +179.01, +179.01, receive incoming, Packet #1, out of, 2, with id, 15, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +179.01, break this packet into, 1 +179.01, enqueing, Packet #1, out of, 2, with id, 15, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +180.20999999999998, dequeuing, Packet #1, out of, 2, with id, 15, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +181.40999999999997, dequeuing, Packet #1, out of, 2, with id, 15, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +190.712599469496, +190.712599469496, receive incoming, Packet #3, out of, 4, with id, 6, from, Output_Res_0, to, User_1, tag, 20, delay, 0.0 +190.712599469496, break this packet into, 1 +190.712599469496, enqueing, Packet #3, out of, 4, with id, 6, from, Output_Res_0, to, User_1, tag, 20 +191.01, dequeuing, Packet #2, out of, 4, with id, 5, from, Output_Res_0, to, User_1, tag, 20 +191.01, +191.01, receive incoming, Packet #1, out of, 2, with id, 16, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +191.01, break this packet into, 1 +191.01, enqueing, Packet #1, out of, 2, with id, 16, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +191.01, +191.01, receive incoming, Packet #1, out of, 2, with id, 16, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +191.01, break this packet into, 1 +191.01, enqueing, Packet #1, out of, 2, with id, 16, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +192.20999999999998, dequeuing, Packet #1, out of, 2, with id, 16, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +193.40999999999997, dequeuing, Packet #1, out of, 2, with id, 16, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +201.91259946949603, +201.91259946949603, receive incoming, Packet #4, out of, 4, with id, 7, from, Output_Res_0, to, User_1, tag, 20, delay, 0.0 +201.91259946949603, break this packet into, 1 +201.91259946949603, enqueing, Packet #4, out of, 4, with id, 7, from, Output_Res_0, to, User_1, tag, 20 +203.01, dequeuing, Packet #3, out of, 4, with id, 6, from, Output_Res_0, to, User_1, tag, 20 +203.01, +203.01, receive incoming, Packet #1, out of, 2, with id, 17, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +203.01, break this packet into, 1 +203.01, enqueing, Packet #1, out of, 2, with id, 17, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +203.01, +203.01, receive incoming, Packet #1, out of, 2, with id, 17, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 0.0 +203.01, break this packet into, 1 +203.01, enqueing, Packet #1, out of, 2, with id, 17, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +204.20999999999998, dequeuing, Packet #1, out of, 2, with id, 17, from, Output_User_0, to, Res_0, tag, GridSimTags.JUNK_PKT +205.40999999999997, dequeuing, Packet #1, out of, 2, with id, 17, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +205.51899946949604, +205.51899946949604, receive incoming, Packet #1, out of, 1, with id, 8, from, Output_Res_0, to, User_0, tag, 23, delay, 0.064 +205.51899946949604, break this packet into, 1 +205.51899946949604, enqueing, Packet #1, out of, 1, with id, 8, from, Output_Res_0, to, User_0, tag, 23 +205.58299946949603, dequeuing, Packet #1, out of, 1, with id, 8, from, Output_Res_0, to, User_0, tag, 23 +205.58299946949603, +205.58299946949603, receive incoming, Packet #1, out of, 1, with id, 9, from, Output_Res_0, to, User_1, tag, 23, delay, 0.0 +205.58299946949603, break this packet into, 1 +205.58299946949603, enqueing, Packet #1, out of, 1, with id, 9, from, Output_Res_0, to, User_1, tag, 23 +206.840599469496, +206.840599469496, receive incoming, Packet #1, out of, 4, with id, 10, from, Output_Res_0, to, User_0, tag, 20, delay, 12.0 +206.840599469496, break this packet into, 1 +206.840599469496, enqueing, Packet #1, out of, 4, with id, 10, from, Output_Res_0, to, User_0, tag, 20 +215.01, dequeuing, Packet #4, out of, 4, with id, 7, from, Output_Res_0, to, User_1, tag, 20 +215.01, +215.01, receive incoming, Packet #1, out of, 2, with id, 18, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 0.0 +215.01, break this packet into, 1 +215.01, enqueing, Packet #1, out of, 2, with id, 18, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +215.01, +215.01, receive incoming, Packet #1, out of, 2, with id, 18, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +215.01, break this packet into, 1 +215.01, enqueing, Packet #1, out of, 2, with id, 18, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +216.20999999999998, dequeuing, Packet #1, out of, 2, with id, 18, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +218.840599469496, dequeuing, Packet #1, out of, 4, with id, 10, from, Output_Res_0, to, User_0, tag, 20 +218.840599469496, +218.840599469496, receive incoming, Packet #2, out of, 4, with id, 11, from, Output_Res_0, to, User_0, tag, 20, delay, 12.0 +218.840599469496, break this packet into, 1 +218.840599469496, enqueing, Packet #2, out of, 4, with id, 11, from, Output_Res_0, to, User_0, tag, 20 +219.01, dequeuing, Packet #1, out of, 1, with id, 9, from, Output_Res_0, to, User_1, tag, 23 +219.07399999999998, dequeuing, Packet #1, out of, 2, with id, 18, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +227.01, +227.01, receive incoming, Packet #1, out of, 2, with id, 19, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +227.01, break this packet into, 1 +227.01, enqueing, Packet #1, out of, 2, with id, 19, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +227.01, +227.01, receive incoming, Packet #1, out of, 2, with id, 19, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 12.0 +227.01, break this packet into, 1 +227.01, enqueing, Packet #1, out of, 2, with id, 19, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +228.20999999999998, dequeuing, Packet #1, out of, 2, with id, 19, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +230.840599469496, dequeuing, Packet #2, out of, 4, with id, 11, from, Output_Res_0, to, User_0, tag, 20 +230.840599469496, +230.840599469496, receive incoming, Packet #3, out of, 4, with id, 12, from, Output_Res_0, to, User_0, tag, 20, delay, 12.0 +230.840599469496, break this packet into, 1 +230.840599469496, enqueing, Packet #3, out of, 4, with id, 12, from, Output_Res_0, to, User_0, tag, 20 +239.01, dequeuing, Packet #1, out of, 2, with id, 19, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +239.01, +239.01, receive incoming, Packet #1, out of, 2, with id, 20, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +239.01, break this packet into, 1 +239.01, enqueing, Packet #1, out of, 2, with id, 20, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +239.01, +239.01, receive incoming, Packet #1, out of, 2, with id, 20, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 12.0 +239.01, break this packet into, 1 +239.01, enqueing, Packet #1, out of, 2, with id, 20, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +240.20999999999998, dequeuing, Packet #1, out of, 2, with id, 20, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +242.04059946949602, +242.04059946949602, receive incoming, Packet #4, out of, 4, with id, 13, from, Output_Res_0, to, User_0, tag, 20, delay, 0.0 +242.04059946949602, break this packet into, 1 +242.04059946949602, enqueing, Packet #4, out of, 4, with id, 13, from, Output_Res_0, to, User_0, tag, 20 +242.840599469496, dequeuing, Packet #3, out of, 4, with id, 12, from, Output_Res_0, to, User_0, tag, 20 +246.840599469496, +246.840599469496, receive incoming, Packet #1, out of, 4, with id, 14, from, Output_Res_0, to, User_1, tag, 20, delay, 0.0 +246.840599469496, break this packet into, 1 +246.840599469496, enqueing, Packet #1, out of, 4, with id, 14, from, Output_Res_0, to, User_1, tag, 20 +251.01, dequeuing, Packet #1, out of, 2, with id, 20, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +251.01, +251.01, receive incoming, Packet #1, out of, 2, with id, 21, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT, delay, 1.2 +251.01, break this packet into, 1 +251.01, enqueing, Packet #1, out of, 2, with id, 21, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +251.01, +251.01, receive incoming, Packet #1, out of, 2, with id, 21, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT, delay, 0.0 +251.01, break this packet into, 1 +251.01, enqueing, Packet #1, out of, 2, with id, 21, from, Output_User_0, to, User_1, tag, GridSimTags.JUNK_PKT +252.20999999999998, dequeuing, Packet #1, out of, 2, with id, 21, from, Output_User_1, to, Res_0, tag, GridSimTags.JUNK_PKT +254.840599469496, dequeuing, Packet #4, out of, 4, with id, 13, from, Output_Res_0, to, User_0, tag, 20 +258.840599469496, +258.840599469496, receive incoming, Packet #2, out of, 4, with id, 15, from, Output_Res_0, to, User_1, tag, 20, delay, 0.0 +258.840599469496, break this packet into, 1 +258.840599469496, enqueing, Packet #2, out of, 4, with id, 15, from, Output_Res_0, to, User_1, tag, 20 +263.01, dequeuing, Packet ... [truncated message content] |