From: <mar...@us...> - 2008-03-09 02:52:01
|
Revision: 141 http://gridsim.svn.sourceforge.net/gridsim/?rev=141&view=rev Author: marcos_dias Date: 2008-03-08 18:52:03 -0800 (Sat, 08 Mar 2008) Log Message: ----------- This update includes an option in the aggressive backfilling policies that allows the user to provide an implementation of comparator, which defines how the queued jobs are ordered. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2008-03-05 02:36:56 UTC (rev 140) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2008-03-09 02:52:03 UTC (rev 141) @@ -3,7 +3,6 @@ * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * */ package gridsim.turbo; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-05 02:36:56 UTC (rev 140) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-09 02:52:03 UTC (rev 141) @@ -503,7 +503,7 @@ // iterates the waiting queue and for each gridlet, put the ranges // used back in the profile. That is, updates the entries - Collections.sort(queuedGridlets_, orderByPriority_); + Collections.sort(queuedGridlets_, jobOrderHeuristic_); Iterator<SSGridlet> iterQueue = queuedGridlets_.iterator(); while(iterQueue.hasNext()) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-05 02:36:56 UTC (rev 140) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-09 02:52:03 UTC (rev 141) @@ -15,6 +15,7 @@ import gridsim.ParameterException; import gridsim.gui.AllocationAction; +import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; @@ -73,7 +74,7 @@ protected LinkedList<SSGridlet> runningGridlets_; // Queue of Gridlets waiting in this queue - protected LinkedList<SSGridlet> queuedGridlets_; + protected ArrayList<SSGridlet> queuedGridlets_; // The rating of one PE protected int ratingPE_; @@ -84,8 +85,8 @@ // The availability profile protected MPAvailabilityProfile profile_; - // to order the gridlets according to their priorities and submission times - protected OrderGridletsByPriority orderByPriority_; + // heuristic used to order the jobs for backfilling + protected Comparator<SSGridlet> jobOrderHeuristic_; // used by the scheduler to specify the priority of the item protected PrioritySelector prioritySelector_; @@ -141,8 +142,8 @@ // initialises local data structure runningGridlets_ = new LinkedList<SSGridlet>(); - queuedGridlets_ = new LinkedList<SSGridlet>(); - orderByPriority_ = new OrderGridletsByPriority(); + queuedGridlets_ = new ArrayList<SSGridlet>(); + jobOrderHeuristic_ = new OrderGridletsByPriority(); numPartitions_ = numPartitions; profile_ = new MPAvailabilityProfile(); prioritySelector_ = null; @@ -188,6 +189,21 @@ } /** + * Sets the heuristic used to order the jobs considered for backfilling + * @param comparator a comparator implementation that defines + * how gridlets are ordered. + * @return <tt>true</tt> if the heuristic was set correctly; + * <tt>false</tt> otherwise. + */ + public boolean setJobOrderingHeuristic(Comparator<SSGridlet> comparator) { + if(comparator == null) + return false; + + jobOrderHeuristic_ = comparator; + return true; + } + + /** * Indicates whether the borrowing of resources of the partitions from * one another is allowed or not. * @param allow <tt>true</tt> indicates that it is allowed; @@ -372,12 +388,8 @@ } sgl.setPartitionID(queueId); - sgl.setStatus(Gridlet.QUEUED); queuedGridlets_.add(sgl); - - // order gridlets according to their priorities - Collections.sort(queuedGridlets_, orderByPriority_); backfillGridlets(GridSim.clock()); //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- @@ -592,14 +604,15 @@ EasyBackFillingPartition queue = getPartition(queueId); - // if queue has a pivot already, then just add - // the job to the waiting queue + // if queue has a pivot already, then check whether the pivot appears + // before in the queue after reordering. If it does, then the job + // to be scheduled becomes the new pivot if(queue.pivot_ != null) { - // checks whether the priority of the pivot is lower than the - // job being considered for scheduling. - // If priority of pivot is higher or equals to sgl's, then do not - // make any change - if(queue.pivot_.getPriority() >= sgl.getPriority()) + + int indexPivot = queuedGridlets_.indexOf(queue.pivot_); + int indexNewGrl = queuedGridlets_.indexOf(sgl); + + if(indexPivot < indexNewGrl) return false; else { profile_.updateEntriesAtProfile(queue.pivot_); @@ -851,6 +864,9 @@ } } + // order gridlets according to the job ordering heuristic provided + Collections.sort(queuedGridlets_, jobOrderHeuristic_); + // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than reference time Iterator<SSGridlet> iter = queuedGridlets_.iterator(); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-03-05 02:36:56 UTC (rev 140) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-03-09 02:52:03 UTC (rev 141) @@ -16,6 +16,8 @@ import gridsim.gui.AllocationAction; import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedList; @@ -83,8 +85,11 @@ protected AvailabilityProfile availProfile_; // the resource characteristics object to be used - protected TResourceCharacteristics resource_; + protected TResourceCharacteristics resource_; + // heuristic used to order the jobs for backfilling + protected Comparator<SSGridlet> jobOrderHeuristic_; + // the last time when the schedule updated was called private double lastScheduleUpdate_; @@ -178,6 +183,21 @@ } /** + * Sets the heuristic used to order the jobs considered for backfilling + * @param comparator a comparator implementation that defines + * how gridlets are ordered. + * @return <tt>true</tt> if the heuristic was set correctly; + * <tt>false</tt> otherwise. + */ + public boolean setJobOrderingHeuristic(Comparator<SSGridlet> comparator) { + if(comparator == null) + return false; + + jobOrderHeuristic_ = comparator; + return true; + } + + /** * Schedules/adds to the queue a new <tt>Gridlet</tt> received by the * <tt>GridResource</tt> entity. * @param gridlet a Gridlet object to be executed @@ -478,7 +498,6 @@ sgl.setPERangeList(selected); // changes the Gridlet status -// sgl.setStatus(Gridlet.QUEUED); sgl.setStartTime(startTime); sgl.setActualFinishTime(finishTime); pivot_ = sgl; @@ -679,6 +698,11 @@ pivot_ = null; } } + + // order jobs according to the ordering heuristic provided. + // That is, if one was provided by the user. + if(jobOrderHeuristic_ != null) + Collections.sort(queuedGridlets_, jobOrderHeuristic_); // Start the execution of Gridlets that are queued Iterator<SSGridlet> iter = queuedGridlets_.iterator(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |