From: <mar...@us...> - 2008-03-01 01:10:39
|
Revision: 138 http://gridsim.svn.sourceforge.net/gridsim/?rev=138&view=rev Author: marcos_dias Date: 2008-02-29 17:10:44 -0800 (Fri, 29 Feb 2008) Log Message: ----------- Additional features in the easy backfilling multi partition policy: + Option to provide a priority selector that indicates what priorities the scheduler should assign to gridlets submitted to the resource. + The user can indicate whether the partitions can borrow resources from one another or not. This may be useful if the user wants to implement complex policies where he controls how the resources are allocated to the partitions. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/PrioritySelector.java Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-02-28 04:11:36 UTC (rev 137) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-01 01:10:44 UTC (rev 138) @@ -87,6 +87,13 @@ // to order the gridlets according to their priorities and submission times protected OrderGridletsByPriority orderByPriority_; + // used by the scheduler to specify the priority of the item + protected PrioritySelector prioritySelector_; + + // indicates whether the borrowing of resources by the + // partitions is allowed or not + private boolean allowBorrowing_; + // the number of partitions or queues in this scheduler protected int numPartitions_; @@ -138,7 +145,9 @@ orderByPriority_ = new OrderGridletsByPriority(); numPartitions_ = numPartitions; profile_ = new MPAvailabilityProfile(); + prioritySelector_ = null; lastScheduleUpdate_ = 0.0D; + allowBorrowing_ = true; ratingPE_ = 0; } @@ -177,6 +186,31 @@ profile_.addPartition(partition); 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; + * <tt>false</tt> otherwise. + */ + public void setAllowBorrowing(boolean allow) { + allowBorrowing_ = allow; + } + + /** + * Sets the priority selector to be used by this scheduler. The selector + * defines what priorities the scheduler should assign to the gridlets. + * @param selector the selector to be used. + * @return <tt>true</tt> if the selector has been defined successfully or + * <tt>false</tt> otherwise. + */ + public boolean setPrioritySelector(PrioritySelector selector) { + if(selector == null || Sim_system.running()) + return false; + + prioritySelector_ = selector; + return true; + } /** * Handles internal events that come to this entity. @@ -227,8 +261,13 @@ PERangeList freeRanges = resource_.getFreePERanges().clone(); for(QueuePartition partition : profile_.getPartitions()) { allocPE += partition.getInitialNumPEs(); - PERangeList selected = - super.selectPERangeList(partition.getInitialNumPEs(), freeRanges); + PERangeList selected = null; + + if(partition.getInitialNumPEs() > 0) + selected = super.selectPERangeList(partition.getInitialNumPEs(), freeRanges); + else + selected = new PERangeList(); + partition.setIdlePERanges(selected); freeRanges = PERangeList.difference(freeRanges, selected); } @@ -281,7 +320,7 @@ public void gridletSubmit(Gridlet gridlet, boolean ack) { int reqPE = gridlet.getNumPE(); - try{ + try { // reject the Gridlet if it requires more PEs than the resource // is able to provide if(reqPE > super.totalPE_){ @@ -296,13 +335,15 @@ return; } } - catch(Exception ex){ + catch(Exception ex) { System.out.println(super.get_name() + ": Exception on submission of a Gridlet"); } // Create a resource Gridlet SSGridlet sgl = new SSGridlet(gridlet); + if(prioritySelector_ != null) + sgl.setPriority(prioritySelector_.getSchedulePriority(sgl)); //-------------- FOR DEBUGGING PURPOSES ONLY -------------- @@ -480,7 +521,7 @@ // If the queue to which the gridlet is assigned does not have the // required PEs, then tries to borrow the additional PEs from other queues - if(!success) { + if(!success && allowBorrowing_) { // gets all available PEs during given time interval PERangeList overallAvailPEs = profile_.getImmediateAvailability(executionTime); @@ -595,14 +636,19 @@ anchor = (Integer)availObjQueue[0]; startTimeQueue=profile_.get(anchor).getTime(); } + + double startTimeAll; + if (!allowBorrowing_) + startTimeAll = Double.MAX_VALUE; + else { + anchor = (Integer)availObj[0]; + startTimeAll=profile_.get(anchor).getTime(); + } - anchor = (Integer)availObj[0]; - double startTimeAll = profile_.get(anchor).getTime(); - // if the time if the selected partition is smaller or the same as // considering all the partitions, so that means that we can select // resources from the selected partition - if(startTimeQueue <= startTimeAll) { + if(startTimeQueue < Double.MAX_VALUE && startTimeQueue <= startTimeAll) { ranges = (PERangeList)availObjQueue[2]; ranges = super.selectPERangeList(reqPE, ranges); @@ -617,7 +663,7 @@ } // If the queue to which the gridlet is assigned does not have the // required PEs, then try to borrow the additional PEs from other queues. - else { + else if (startTimeAll < Double.MAX_VALUE) { PERangeList addRanges = (PERangeList)availObj[2]; // the anchor index, the entry in the profile where @@ -653,6 +699,9 @@ profile_.allocatePERanges(queueId, anchorIndex, tailIndex, ranges, startTime, finishTime); } + else { + return false; + } queue.pivot_ = sgl; @@ -660,7 +709,6 @@ sgl.setPERangeList(ranges); // change Gridlet status -// sgl.setStatus(Gridlet.QUEUED); sgl.setStartTime(startTime); sgl.setActualFinishTime(finishTime); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-02-28 04:11:36 UTC (rev 137) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-01 01:10:44 UTC (rev 138) @@ -37,7 +37,7 @@ super(); queues_ = new HashMap<Integer, QueuePartition>(); } - + /** * Returns the number of PEs assigned to the partitions * @return the number of PEs assigned to the partitions @@ -266,7 +266,7 @@ * @return the list of ranges of PEs available */ public PERangeList getImmediateAvailability(double duration) { - + double startTime = GridSim.clock(); // start time is now // the gridlet's expected finish time @@ -426,7 +426,7 @@ * array[2] = the list of PEs available at that time */ public Object[] checkPERangesAvailability(int reqPE, double duration) { - + // the anchor index, the entry in the profile where // the gridlet will be placed OR the closest entry to the // point where the anchor of the advance reservation will be placed Added: branches/gridsim4.0-branch3/source/gridsim/turbo/PrioritySelector.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PrioritySelector.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PrioritySelector.java 2008-03-01 01:10:44 UTC (rev 138) @@ -0,0 +1,30 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +/** + * This interface is used by a scheduler to obtain the priority of a given + * schedule item (i.e. gridlet or advance reservation). This information is + * used by allocation policies that use priorities + * such as {@link EBMultiplePartitions}. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + */ + +public interface PrioritySelector { + + /** + * Returns the priority of the item to be assigned by the scheduler + * or allocation policy. + * @param item the item whose priority needs to be obtained. + * @return the priority of the schedule item or <tt>-1</tt> if unknown. + */ + int getSchedulePriority(ScheduleItem item); + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |