From: <mar...@us...> - 2008-03-21 23:28:34
|
Revision: 163 http://gridsim.svn.sourceforge.net/gridsim/?rev=163&view=rev Author: marcos_dias Date: 2008-03-21 16:10:38 -0700 (Fri, 21 Mar 2008) Log Message: ----------- This update fixes a bug in the advance reservation policies. Immediate reservations could be refused if the start time was slightly smaller than current time. If the start time of an advance reservation is smaller than the current time, then the start time will be changed to current simulation time. Modified Paths: -------------- 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 Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-19 08:30:54 UTC (rev 162) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-21 23:10:38 UTC (rev 163) @@ -302,7 +302,7 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); - if(startTime == 0) + if(startTime == 0 || startTime < currentTime) startTime = currentTime; // creates a Server Side Reservation (i.e. SSReservation) @@ -356,9 +356,16 @@ " PEs from " + startTime + " to " + (startTime + duration)); System.out.println("--> The resource could not handle the reservation."); + // Gets availability information and provides it as options + AvailabilityInfo availability = super.allowBorrowing_ ? + getAvailabilityInfo(startTime, Integer.MAX_VALUE) : + getAvailabilityInfo(sRes.getPartitionID(), + startTime, Integer.MAX_VALUE); + reservation.setStatus(Reservation.STATUS_FAILED); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - sendARMessage(response); + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + sendARMessage(response); return; } @@ -700,7 +707,8 @@ * entries that correspond to the availability profile between the times * specified by the requester. */ - protected AvailabilityInfo getAvailabilityInfo(double startTime, int duration) { + protected AvailabilityInfo getAvailabilityInfo(double startTime, + int duration) { AvailabilityInfo list = new AvailabilityInfo(); int anchorIndex = -1; @@ -1012,9 +1020,10 @@ // updates the availability profile accordingly profile_.allocateImmediateRanges(queueId, startTime + duration, selected); + return true; } // Tries all the queues - else { + else if (super.allowBorrowing_) { // gets all available PEs during given time interval PERangeList overallAvailPEs = @@ -1030,22 +1039,19 @@ // additional PEs required int addRequired = reqPE - ranges.getNumPE(); - if(addRanges != null && addRanges.getNumPE() >= addRequired) { - // borrows the additional PEs required from the partitions - // and adds them into the specified queue - addRanges = super.selectPERangeList(addRequired, addRanges); - profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); + // borrows the additional PEs required from the partitions + // and adds them into the specified queue + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); - // allocates the ranges to the gridlet - ranges.addAll(addRanges); - profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); - res.setPERangeList(ranges); - } - else { - return false; - } + // allocates the ranges to the gridlet + ranges.addAll(addRanges); + profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); + res.setPERangeList(ranges); + return true; } - return true; + + return false; } /* @@ -1089,8 +1095,10 @@ // allocates the ranges and updates the availability profile profile_.allocatePERanges(queueId, anchorIndex, tailIndex, selected, startTime, res.getActualFinishTime()); + + return true; } - else { + else if (super.allowBorrowing_) { // number of additional PEs required int addRequired = reqPE - ranges.getNumPE(); @@ -1131,9 +1139,11 @@ ranges, startTime, startTime + duration); res.setPERangeList(ranges); + + return true; } - return true; + return false; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-19 08:30:54 UTC (rev 162) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-21 23:10:38 UTC (rev 163) @@ -306,7 +306,7 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); - if(startTime == 0) + if(startTime == 0 || startTime < currentTime) startTime = currentTime; // creates a Server Side Reservation (i.e. SSReservation) @@ -360,9 +360,16 @@ " PEs from " + startTime + " to " + (startTime + duration)); System.out.println("--> The resource could not handle the reservation."); + // Gets availability information and provides it as options + AvailabilityInfo availability = super.allowBorrowing_ ? + getAvailabilityInfo(startTime, Integer.MAX_VALUE) : + getAvailabilityInfo(sRes.getPartitionID(), + startTime, Integer.MAX_VALUE); + reservation.setStatus(Reservation.STATUS_FAILED); - response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - sendARMessage(response); + reservation.setReservationOptions(availability); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); + sendARMessage(response); return; } @@ -1019,9 +1026,11 @@ // updates the availability profile accordingly profile_.allocateImmediateRanges(queueId, startTime + duration, selected); + + return true; } // Tries all the queues - else { + else if (super.allowBorrowing_) { // gets all available PEs during given time interval PERangeList overallAvailPEs = @@ -1037,22 +1046,20 @@ // additional PEs required int addRequired = reqPE - ranges.getNumPE(); - if(addRanges != null && addRanges.getNumPE() >= addRequired) { - // borrows the additional PEs required from the partitions - // and adds them into the specified queue - addRanges = super.selectPERangeList(addRequired, addRanges); - profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); + // borrows the additional PEs required from the partitions + // and adds them into the specified queue + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); - // allocates the ranges to the gridlet - ranges.addAll(addRanges); - profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); - res.setPERangeList(ranges); - } - else { - return false; - } + // allocates the ranges to the gridlet + ranges.addAll(addRanges); + profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); + res.setPERangeList(ranges); + + return true; } - return true; + + return false; } /* @@ -1096,8 +1103,10 @@ // allocates the ranges and updates the availability profile profile_.allocatePERanges(queueId, anchorIndex, tailIndex, selected, startTime, res.getActualFinishTime()); + + return true; } - else { + else if(super.allowBorrowing_) { // number of additional PEs required int addRequired = reqPE - ranges.getNumPE(); @@ -1138,9 +1147,11 @@ ranges, startTime, startTime + duration); res.setPERangeList(ranges); + + return true; } - return true; + return false; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-19 08:30:54 UTC (rev 162) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-21 23:10:38 UTC (rev 163) @@ -239,7 +239,7 @@ boolean success = true; // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + if(startTime == 0 || startTime <= currentTime) { // sets the start time of the reservation as the current time startTime = currentTime; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |