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