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] |