From: <mar...@us...> - 2008-03-18 00:40:33
|
Revision: 161 http://gridsim.svn.sourceforge.net/gridsim/?rev=161&view=rev Author: marcos_dias Date: 2008-03-17 17:40:38 -0700 (Mon, 17 Mar 2008) Log Message: ----------- This update contains: + An additional item in the Options menu at the ResourceWindow that allows the user to visualise to which partition the jobs belong + A bug fix in the advance reservation features of the multiple partition policies. There were overlaps of advance reservations and normal jobs when using advance reservations. The transfer of PEs to the queue to which the advance reservation belongs, was not being done correctly. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-18 00:40:38 UTC (rev 161) @@ -96,10 +96,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-18 00:40:38 UTC (rev 161) @@ -96,10 +96,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-18 00:40:38 UTC (rev 161) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-03-18 00:40:38 UTC (rev 161) @@ -43,12 +43,17 @@ private Composite transparentComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); - private final Color[] colorQueued = createPalette(153, 153, 255, 40, 6); - private final Color[] colorDone = createPalette(204, 204, 204, 30, 6); - private final Color[] colorInExec = createPalette(255, 255, 102, 25, 6); - private final Color[] colorARNonCommitted = createPalette(153, 255, 153, 51, 6); - private final Color[] colorARCommitted = createPalette(153, 255, 255, 51, 6); - private final Color[] colorARInProgress = createPalette(255, 102, 102, 25, 6); + private final int colorPerPalette = 6; + private final Color[] colorQueued = createPalette(153, 153, 255, 40, colorPerPalette); + private final Color[] colorDone = createPalette(204, 204, 204, 30, colorPerPalette); + private final Color[] colorInExec = createPalette(255, 255, 102, 25, colorPerPalette); + private final Color[] colorARNonCommitted = createPalette(153, 255, 153, 51, colorPerPalette); + private final Color[] colorARCommitted = createPalette(153, 255, 255, 51, colorPerPalette); + private final Color[] colorARInProgress = createPalette(255, 102, 102, 25, colorPerPalette); + private final Color[] colorQueues = + new Color[]{Color.WHITE, Color.RED, Color.GREEN, Color.CYAN, + Color.DARK_GRAY, Color.MAGENTA, Color.ORANGE, Color.PINK, + Color.YELLOW, Color.BLUE}; private static GUISettings settingsInstance_ = null; @@ -63,7 +68,7 @@ return settingsInstance_; } - + /** * Gets the time span for the GUI components * @return the time span for the GUI components @@ -238,6 +243,13 @@ return colors; } + /** + * Return the colours to be used for the partitions + * @return the colors for the partitions + */ + public Color[] getQueueColors() { + return this.colorQueues; + } /** * Returns an array of colours Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-03-18 00:40:38 UTC (rev 161) @@ -110,6 +110,7 @@ private boolean drawID_ = true; private boolean autoScroll_ = true; private boolean animate_ = true; + private boolean showPartition_ = false; private JButton btSetSdWindowSize_; private JTextField fdSdWindowSize_; @@ -142,6 +143,7 @@ private Color[] colorsARNonCommitted; private Color[] colorsARCommitted; private Color[] colorsARInProgress; + private Color[] colorQueues; private static final int WINDOW_WIDTH = 900; private static final int WINDOW_HEIGHT = 350; @@ -185,6 +187,7 @@ colorsARNonCommitted = settings_.getARNonCommittedColors(); colorsARCommitted = settings_.getARCommittedColors(); colorsARInProgress = settings_.getARInProgressColors(); + colorQueues = settings_.getQueueColors(); } // -------------------------- PUBLIC METHODS ----------------------- @@ -476,6 +479,25 @@ menuCommand.add(mnAnimation); + JMenu mnPartition = new JMenu("Partitions"); + JCheckBoxMenuItem miPartition = new JCheckBoxMenuItem("Show Partition Informations"); + miPartition.setSelected(false); + mnPartition.add(miPartition); + + miPartition.addItemListener(new ItemListener(){ + public void itemStateChanged(ItemEvent e){ + if (e.getStateChange() == ItemEvent.DESELECTED){ + showPartition_ = false; + } + else if (e.getStateChange() == ItemEvent.SELECTED){ + showPartition_ = true; + } + updateResourceWindow(); + } + }); + + menuCommand.add(mnPartition); + menuBar.add(menuCommand); setJMenuBar(menuBar); } @@ -698,10 +720,13 @@ continue; int itemId = item.getID(); - if (item.getPERangeList() != null){ + if (item.getPERangeList() != null) { // the color of the font for normal gridlets is black fontColor = Color.BLACK; - if(!item.isAdvanceReservation()) { + if(showPartition_) { + boxColor = colorQueues[item.getPartitionID() % colorQueues.length]; + } + else if(!item.isAdvanceReservation()) { // Gridlet is in execution if(item.getStatus() == Gridlet.INEXEC){ boxColor = colorsInExec[(itemId % colorsInExec.length)]; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -302,6 +302,9 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); + if(startTime == 0) + startTime = currentTime; + // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); @@ -335,8 +338,8 @@ boolean success = true; - // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + // if start time = current time, then it is an immediate reservation + if(startTime == currentTime) { success = handleImmediateReservation(sRes); expTime = sRes.getActualFinishTime(); } @@ -1088,19 +1091,31 @@ tailIndex, selected, startTime, res.getActualFinishTime()); } else { + + // number of additional PEs required + int addRequired = reqPE - ranges.getNumPE(); - // check when enough PEs to handle the gridlet will be available + // check when enough PEs to handle the gridlet will be available // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(startTime, duration); + // removes PEs already obtained from selected partition PERangeList addRanges = availObj == null ? - new PERangeList() : (PERangeList)availObj[2]; + new PERangeList() : + PERangeList.difference((PERangeList)availObj[2], ranges); - if(addRanges.getNumPE() < reqPE) - return false; + if(addRanges == null || addRanges.getNumPE() < addRequired) + return false; - addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + // selects and transfers PEs to the queue o which the AR belongs + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, + startTime, startTime + duration); + + // now get the availability of the queue again + availObj = profile_.checkPERangesAvailability(queueId, + startTime, duration); // the anchor index, the entry in the profile where // the gridlet will be placed @@ -1109,16 +1124,11 @@ // corresponding to the gridlet's finish time will be placed int tailIndex = (Integer)availObj[1]; - // borrows the ranges from the queues and adds it into the - // specified queue - profile_.transferPEs(queueId, addRanges, startTime, - startTime + duration); - // finally allocate the ranges to the gridlet - ranges.addAll(addRanges); + ranges = super.selectPERangeList(reqPE, (PERangeList)availObj[2]); profile_.allocatePERanges(queueId, anchorIndex, tailIndex, - ranges, startTime, startTime + duration); + ranges, startTime, startTime + duration); res.setPERangeList(ranges); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -306,6 +306,9 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); + if(startTime == 0) + startTime = currentTime; + // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); @@ -337,10 +340,10 @@ return; } - boolean success = true; + boolean success = false; - // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + // if start time = current time, then it is an immediate reservation + if(startTime == currentTime) { success = handleImmediateReservation(sRes); expTime = sRes.getActualFinishTime(); } @@ -917,7 +920,8 @@ //-------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- // If a gridlet has been cancelled, then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, removedRes); + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_CANCELLED, true, removedRes); //----------------------------------------------------------------- @@ -930,7 +934,8 @@ // If a gridlet has started execution or one has finished, // then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + GridSim.notifyListeners(this.get_id(), + AllocationAction.SCHEDULE_CHANGED, true); //----------------------------------------------------------------- } @@ -1093,37 +1098,44 @@ tailIndex, selected, startTime, res.getActualFinishTime()); } else { - - // check when enough PEs to handle the gridlet will be available + + // number of additional PEs required + int addRequired = reqPE - ranges.getNumPE(); + + // check when enough PEs to handle the gridlet will be available // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(startTime, duration); - + + // removes PEs already obtained from selected partition PERangeList addRanges = availObj == null ? - new PERangeList() : (PERangeList)availObj[2]; + new PERangeList() : + PERangeList.difference((PERangeList)availObj[2], ranges); - if(addRanges.getNumPE() < reqPE) + if(addRanges == null || addRanges.getNumPE() < addRequired) return false; - - addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + // selects and transfers PEs to the queue o which the AR belongs + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, + startTime, startTime + duration); + + // now get the availability of the queue again + availObj = profile_.checkPERangesAvailability(queueId, + startTime, duration); + // the anchor index, the entry in the profile where // the gridlet will be placed int anchorIndex = (Integer)availObj[0]; // insert index represents the position after which the entry // corresponding to the gridlet's finish time will be placed int tailIndex = (Integer)availObj[1]; - - // borrows the ranges from the queues and adds it into the - // specified queue - profile_.transferPEs(queueId, addRanges, startTime, - startTime + duration); - + // finally allocate the ranges to the gridlet - ranges.addAll(addRanges); + ranges = super.selectPERangeList(reqPE, (PERangeList)availObj[2]); profile_.allocatePERanges(queueId, anchorIndex, tailIndex, - ranges, startTime, startTime + duration); + ranges, startTime, startTime + duration); res.setPERangeList(ranges); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-18 00:40:38 UTC (rev 161) @@ -1322,10 +1322,6 @@ tailIndex++; } - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - if (anchorIndex > -1) { AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); @@ -1356,6 +1352,10 @@ availProfile_.add(anchorIndex, newEntryAfterAnchor); tailIndex++; } + + if(addEntryAfterTail) { + availProfile_.add(tailIndex, newEntryAfterTail); + } // Update entries of the profile if(tailIndex > -1) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -411,6 +411,39 @@ // --------------------- PROTECTED METHODS ----------------------- + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether there are + * gridlets in the waiting list that should start execution. It also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + + double currentTime = GridSim.clock(); + + // then finishes the Gridlets whose start time is smaller + // or equals to the current simulation time + int itemsFinished = finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + MPProfileEntry currentStatus = profile_.removePastEntries(currentTime); + if(currentStatus != null) { + profile_.setCurrentStatus(currentStatus); + resource_.resetFreePERanges(currentStatus.getPERanges()); + } + + // Start the execution of Gridlets that are queued and whose + // potential start execution time is smaller than current time + int itemsStarted = startQueuedGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0){ + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + } + } /** * This method finalises the gridlets in execution whose time Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -93,7 +93,7 @@ // indicates whether the borrowing of resources by the // partitions is allowed or not - private boolean allowBorrowing_; + protected boolean allowBorrowing_; // the number of partitions or queues in this scheduler protected int numPartitions_; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-18 00:40:38 UTC (rev 161) @@ -214,7 +214,7 @@ if (tailEntry == null) { MPProfileEntry newTail = createHeadEntry(finishTime); - super.add(super.indexOf(tailEntry) + 1, newTail); + super.add(0, newTail); } else if(tailEntry.getTime() < finishTime) { MPProfileEntry newTail = tailEntry.clone(finishTime); @@ -520,11 +520,11 @@ } /** - * Allocate processing elements to a gridlet + * Allocate processing elements to a gridlet/reservation * @param queueId the id of the gridlet's selected partition * @param anchorIndex the index of the entry used as anchor - * @param tailIndex the index of the last entry close to the gridlet's - * finish time + * @param tailIndex the index of the last entry close to the + * gridlet's finish time * @param selected the selected ranges of PEs * @param startTime the gridlet's start time * @param finishTime the gridlet's finish time @@ -573,10 +573,6 @@ tailIndex++; } - if(addEntryAfterTail) { - super.add(tailIndex, newEntryAfterTail); - } - if (anchorIndex > -1) { MPProfileEntry anchorEntry = super.get(anchorIndex); @@ -605,6 +601,10 @@ super.add(anchorIndex, newEntryAfterAnchor); tailIndex++; } + + if(addEntryAfterTail) { + super.add(tailIndex, newEntryAfterTail); + } // Update entries of the profile if(tailIndex > -1) { @@ -865,6 +865,23 @@ public void transferPEs(int recQueueId, PERangeList list, double startTime, double finishTime) { +// // creates a new entry to be used as the tail for the +// // time slot transfered to another queue. This is required to +// // mark the finish time of a slot given to an advance reservation +// MPProfileEntry tailEntry = getPrecedingEntry(finishTime); +// if(tailEntry != null && tailEntry.getTime() < finishTime) { +// int newTailIndex = super.indexOf(tailEntry) + 1; +// MPProfileEntry newTailEntry = tailEntry.clone(finishTime); +// super.add(newTailIndex, newTailEntry); +// } +// else if (tailEntry != null && tailEntry.getTime() == finishTime) { +// tailEntry.increaseGridlet(); +// } +// else if (tailEntry == null) { +// MPProfileEntry newTailEntry = createHeadEntry(finishTime); +// super.add(0, newTailEntry); +// } + // if start time is equals to current time, then we have // to transfer ranges across the idle pes as well if(startTime <= GridSim.clock()) { @@ -877,15 +894,32 @@ queue.getIdlePERanges().addAll(list.clone()); queue.getIdlePERanges().mergePERanges(); } + else { + // creates a new entry to be used as anchor for the + // time slot transfered to another queue. This is required to + // mark the start time of a slot given to an advance reservation + MPProfileEntry anchorEntry = getPrecedingEntry(startTime); + + if (anchorEntry == null) { + MPProfileEntry newAnchorEntry = createHeadEntry(startTime); + super.add(0, newAnchorEntry); + } + else if(anchorEntry.getTime() < startTime) { + MPProfileEntry newAnchorEntry = anchorEntry.clone(startTime); + super.add(super.indexOf(anchorEntry) + 1, newAnchorEntry); + } + } // transfer the ranges for(int i=0; i<super.size(); i++) { MPProfileEntry nextEntry = super.get(i); - if(nextEntry.getTime() < startTime) + if(nextEntry.getTime() < startTime) { continue; - if(nextEntry.getTime() >= finishTime) + } + if(nextEntry.getTime() >= finishTime) { // if(nextEntry.getTime() > finishTime) break; + } else { nextEntry.transferPEs(recQueueId, list); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |