From: <mar...@us...> - 2007-11-05 01:07:01
|
Revision: 77 http://gridsim.svn.sourceforge.net/gridsim/?rev=77&view=rev Author: marcos_dias Date: 2007-11-04 17:07:03 -0800 (Sun, 04 Nov 2007) Log Message: ----------- This update contains some small bug fixes and changes in names of some classes. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java Removed Paths: ------------- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-11-05 01:07:03 UTC (rev 77) @@ -13,7 +13,7 @@ import gridsim.GridletList; import gridsim.turbo.Reservation; import gridsim.turbo.ReservationRequester; -import gridsim.turbo.TimeSlotList; +import gridsim.turbo.AvailabilityInfo; import java.util.ArrayList; import java.util.Calendar; @@ -180,7 +180,7 @@ resName = (String) resNameList.get(val); // queries the availability of the Grid resource - TimeSlotList availability = + AvailabilityInfo availability = super.queryFreeTime(GridSim.clock(), Integer.MAX_VALUE, resID); System.out.println("Availability information returned by the " + Modified: branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java 2007-11-05 01:07:03 UTC (rev 77) @@ -10,14 +10,10 @@ package gridsim; import java.util.Calendar; -import java.util.LinkedList; import eduni.simjava.Sim_entity; import eduni.simjava.Sim_event; import eduni.simjava.Sim_port; -import gridsim.gui.AllocationAction; -import gridsim.gui.DefaultGridSimVisualizer; -import gridsim.turbo.ScheduleItem; /** * AllocPolicy is an abstract class that handles the internal Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2007-11-05 01:07:03 UTC (rev 77) @@ -787,7 +787,7 @@ * @param item the item whose information has to be updated */ protected void updateItem(ScheduleItem item) { - int position = getPosition(item.getID(), item.getUserID(), + int position = getPosition(item.getID(), item.getSenderID(), item.isAdvanceReservation()); if(position < 0) { @@ -877,7 +877,7 @@ */ private String itemSummary(ScheduleItem item) { return (item.isAdvanceReservation() ? "Res. " : "Grl. ") + "ID: " + item.getID() + - ", User: " + item.getUserID(); + ", User: " + item.getSenderID(); } /** @@ -902,7 +902,7 @@ for (int i = 0; i < sizeVector; i++) { item = items_.get(i); if (item.getID() == itemId - && item.getUserID() == userId + && item.getSenderID() == userId && item.isAdvanceReservation() == ar) return i; } @@ -933,7 +933,7 @@ if(submittedTime == item.getSubmissionTime() && insertItem.getID() == item.getID() && insertItem.isAdvanceReservation() == item.isAdvanceReservation() - && insertItem.getUserID() == item.getUserID() ) { + && insertItem.getSenderID() == item.getSenderID() ) { return i; } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2007-11-05 01:07:03 UTC (rev 77) @@ -32,7 +32,7 @@ // by informing the reservation requester when resource will be available to // fulfil the reservation. This attribute contains the list of PEs // available at a set of simulation times - private TimeSlotList resOptions_; + private AvailabilityInfo resOptions_; // the price associate with this message private double price_; @@ -383,7 +383,7 @@ * Gets the reservation options given by the Grid resource * @return the reservation options */ - public TimeSlotList getReservationOptions() { + public AvailabilityInfo getReservationOptions() { return resOptions_; } @@ -391,7 +391,7 @@ * Sets the reservation options given by the Grid resource * @param resOptions the reservation options object */ - public void setReservationOptions(TimeSlotList resOptions) { + public void setReservationOptions(AvailabilityInfo resOptions) { resOptions_ = resOptions; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-11-05 01:07:03 UTC (rev 77) @@ -140,13 +140,13 @@ // internal event tags used by this gridlet // a tag to denote expiry time - private final int EXPIRY_TIME = 12; + private static final int EXPIRY_TIME = 12; // a tag to indicate that a reservation has to start - private final int START_RESERVATION = 13; + private static final int START_RESERVATION = 13; // a tag to indicate that a reservation has to finish - private final int FINISH_RESERVATION = 14; + private static final int FINISH_RESERVATION = 14; // a tag to indicate that a gridlet has finished private static final int GRIDLET_FINISHED = 10; @@ -630,7 +630,7 @@ * Handles a query free time request. * @param message the advance reservation message received. */ - public void handleQueryFreeTime(ARMessage message) { + public void handleQueryAvailability(ARMessage message) { // gets the reservation id of the message Reservation reservation = message.getReservation(); @@ -643,7 +643,7 @@ int duration = reservation.getDurationTime(); // gets the availability information from the availability profile - TimeSlotList availability = getAvailabilityInfo(startTime, duration); + AvailabilityInfo availability = getAvailabilityInfo(startTime, duration); // sets the options as the availability over the requested period response.setReservationOptions(availability); @@ -2298,9 +2298,9 @@ * entries that correspond to the availability profile between the times * specified by the requester. */ - private TimeSlotList getAvailabilityInfo(double startTime, int duration) { + private AvailabilityInfo getAvailabilityInfo(double startTime, int duration) { - TimeSlotList list = new TimeSlotList(); + AvailabilityInfo list = new AvailabilityInfo(); int anchorIndex = -1; // if the user specified the start time as 0, it means that the @@ -2319,7 +2319,7 @@ // a pointer to the anchor entry (described above) AvailabilityProfileEntry anchorEntry = null; int length = availProfile_.size(); - TimeSlotEntry firstEntry = null; + AvailabilityInfoEntry firstEntry = null; double entryTime; @@ -2340,15 +2340,17 @@ // before the first entry of the profile, so the intersection list // has to start with the ranges of PEs currently available if (anchorEntry == null) { + PERangeList peList = (resource_.getFreePERanges() == null) ? null : + resource_.getFreePERanges().clone(); firstEntry = - new TimeSlotEntry(startTime, resource_.getFreePERanges().clone()); + new AvailabilityInfoEntry(startTime, peList); } else { PERangeList newList = anchorEntry.getPERanges(); if(newList != null) { newList = newList.clone(); } - firstEntry = new TimeSlotEntry(startTime, newList); + firstEntry = new AvailabilityInfoEntry(startTime, newList); anchorIndex = availProfile_.indexOf(anchorEntry); } @@ -2369,14 +2371,15 @@ if(peList != null) { peList = peList.clone(); } - TimeSlotEntry tsEntry = - new TimeSlotEntry(nextEntry.getTime(), peList.clone()); + AvailabilityInfoEntry tsEntry = + new AvailabilityInfoEntry(nextEntry.getTime(), peList); list.add(tsEntry); } previousEntry = nextEntry; } } + list.sort(); // sort the list before send it back return list; } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2007-11-05 01:07:03 UTC (rev 77) @@ -172,6 +172,8 @@ */ private void initARPolicy() throws Exception { try{ + arPolicy_ = (ARTPolicy)super.policy_; + if(arPolicy_ == null && policyType_ == TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED) { arPolicy_ = (ARParallelSpaceShared)policy_; @@ -263,7 +265,7 @@ break; case ARMessage.TYPE_AR_LIST_FREE_TIME: - arPolicy_.handleQueryFreeTime(message); + arPolicy_.handleQueryAvailability(message); break; } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2007-11-05 01:07:03 UTC (rev 77) @@ -109,7 +109,7 @@ * @param message the advance reservation message received * @pre message != null */ - public abstract void handleQueryFreeTime(ARMessage message); + public abstract void handleQueryAvailability(ARMessage message); //-------------------- END OF ABSTRACT METHODS -------------------- Copied: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java (from rev 76, branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java) =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2007-11-05 01:07:03 UTC (rev 77) @@ -0,0 +1,312 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; + +/** + * The {@link AvailabilityInfo} class represents a list of entries + * that represent the availability of PES of a Grid resource over + * a period of time. This is used in return to a query availability + * in an advance reservation based allocation policy. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see ARTPolicy + * @see PERange + * @see PERangeList + * @see ARParallelSpaceShared + * @see ARParallelSpaceShared#handleQueryAvailability(ARMessage) + */ + +public class AvailabilityInfo { + + private static final long serialVersionUID = -3951650752024908016L; + + private ArrayList<AvailabilityInfoEntry> list_; + private double startTime_; + private double finishTime_; + + private static final int UNKNOWN = -1; + + /** + * Default constructor. + */ + public AvailabilityInfo() { + list_ = new ArrayList<AvailabilityInfoEntry>(); + startTime_ = UNKNOWN; + finishTime_ = UNKNOWN; + } + + /** + * Returns the start time of this list. That is, + * the time of the first element of this list + * @return the start time + */ + public double getStartTime() { + return startTime_; + } + + /** + * Returns the end time of this list. + * @return the end time + */ + public double getEndTime() { + return finishTime_; + } + + /** + * Sets the start time of this list. + * @param startTime the start time + */ + public void setStartTime(double startTime) { + startTime_ = startTime; + } + + /** + * Sets the end time of this list. + * @param finishTime the end time + */ + public void setFinishTime(double finishTime) { + finishTime_ = finishTime; + } + + /** + * Adds the specified element to this list. + * @param entry the entry to be added to this list + * @return <tt>true + */ + public boolean add(AvailabilityInfoEntry entry) { + if(entry == null) { + return false; + } + else { + list_.add(entry); + } + return true; + } + + /** + * Sorts the entries of this availability info object. + */ + public void sort() { + Collections.sort(list_); + } + + /** + * Adds all of the elements in the specified Collection to this list, + * The behaviour of this operation is undefined if the specified + * Collection is modified while the operation is in progress. + * (This implies that the behaviour of this call is undefined if the + * specified Collection is this list, and this list is nonempty.) + * @param collection the collection to be included in this list + * @return <tt>true<tt> if the collection has been added successfully + * or <tt>false</tt> otherwise. + */ + public boolean addAll(Collection<? extends AvailabilityInfoEntry> collection) { + boolean result = true; + + // adds the collection to the list and sets the start + // and finish time again + if(collection != null && !collection.isEmpty()) { + list_.addAll(collection); + } + return result; + } + + /** + * Removes all elements from the list. + */ + public void clear() { + list_.clear(); + } + + /** + * Returns a shallow copy of this list. + * (The elements themselves are not copied.) + */ + public Object clone() { + return list_.clone(); + } + + /** + * Returns <tt>true</tt> if this list contains the specified element. + * @param entry the entry whose presence in this List is to be tested. + * @return <tt>true</tt> if the specified element is present; + * <tt>false</tt> otherwise. + */ + public boolean contains(Object entry) { + return list_.contains(entry); + } + + /** + * Returns the element at the specified position in this list. + * @param index the index of the element to return + * @return the element at the specified position in this list. + */ + public AvailabilityInfoEntry get(int index) { + return list_.get(index); + } + + /** + * Searches for the first occurence of the given argument, + * testing for equality using the equals method. + * @param entry the entry whose index is to be returned + * @return the index of the first occurrence of the argument + * in this list; returns <tt>-1</tt> if the object is not found. + */ + public int indexOf(Object entry) { + return list_.indexOf(entry); + } + + /** + * Tests if this list has no elements. + * @return <tt>true</tt> if the list has no elements. + */ + public boolean isEmpty() { + return list_.isEmpty(); + } + + /** + * Returns an iterator over the elements in this list in proper sequence. + * @return the iterator. + */ + public Iterator<AvailabilityInfoEntry> iterator() { + return list_.iterator(); + } + + /** + * Removes the element at a given index + * @param index the index of the element to be removed + * @return the removed element. + */ + public AvailabilityInfoEntry remove(int index) { + return list_.remove(index); + } + + /** + * Removes a given element from the list. + * @param entry the entry to be removed + * @return <tt>true</tt> if the collection contained the + * specified entry. + */ + public boolean remove(Object entry) { + return list_.remove(entry); + } + + /** + * Returns the size of this list. + * @return the size of this list + */ + public int size() { + return list_.size(); + } + + /** + * Scans the entries in a list and returns the first time frame over + * which a request with the characteristics provided can be scheduled + * @param duration the duration of the request + * @param reqPE the number of PEs required + * @return the start time or <tt>-1</tt> if not found + */ + public double getPotentialStartTime(int duration, int reqPE) { + + // the anchor index, the entry in the profile where + // the request would be placed OR the closest entry to the + // point where the anchor of the request would be placed + int anchorIndex = -1; + + // a pointer to the anchor entry (described above) + AvailabilityInfoEntry anchorEntry = null; + + // the list of selected ranges + PERangeList intersectList = null; + + double potStartTime = -1; // keep the potential start time of the request + double potFinishTime = -1; // store the gridlet's expected finish time + + intersectList = null; + int length = list_.size(); + + Iterator<AvailabilityInfoEntry> iterProfile = list_.iterator(); + while(iterProfile.hasNext()) { + + AvailabilityInfoEntry entry = iterProfile.next(); + anchorEntry = entry; + anchorIndex = list_.indexOf(anchorEntry); + + // sets the start time as the time of the entry + potStartTime = entry.getTime(); + // calculates when the finish time will be if + // the gridlet is put at this position + potFinishTime = potStartTime + duration; + + // scan the profile until an entry with enough PEs is found + if(entry.getNumPE() < reqPE) { + continue; + } + else { + // if an entry with enough PEs is found, then scan the list + // from that point onwards analysing the intersection of + // the ranges available in the entries until the + // request expected completion time + intersectList = entry.getAvailRanges().clone(); + + // Look for the intersection of available ranges from + // the anchor until the end of the profile or until + // the entries are further than the expected completion time + for(int i=anchorIndex+1; i<length; i++){ + AvailabilityInfoEntry nextEntry = list_.get(i); + if(nextEntry.getTime() > potFinishTime){ + break; + } + else{ + // if the finish time is equals to the entry time, so there + // is no need to check the intersection + if(nextEntry.getTime() < potFinishTime) { + intersectList = PERangeList.intersection(intersectList, + nextEntry.getAvailRanges()); + if(intersectList == null || intersectList.getNumPE() < reqPE) { + break; + } + } + } + } + // If a time slot with enough PEs has been found, then stop the search + if(intersectList != null && intersectList.getNumPE() >= reqPE) { + break; + } + } + } + + // if the potential finish time is larger than the end time of + // this list, then the request cannot be scheduled + if(potFinishTime > finishTime_) { + potStartTime = UNKNOWN; + } + + return potStartTime; + } + + /** + * Creates a string representation of the list + * @return a string representation + */ + public String toString() { + String result = "Availability={\n"; + for(AvailabilityInfoEntry entry : list_){ + result += entry + "\n"; + } + result += "}"; + return result; + } +} Copied: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java (from rev 76, branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java) =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java 2007-11-05 01:07:03 UTC (rev 77) @@ -0,0 +1,129 @@ +/* + * 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; + +/** + * The {@link AvailabilityInfoEntry} class represents an entry in a list of + * time slots available, which can be allocated to a user. This is used + * in return to a query for free time slots in an advance reservation + * based allocation policy. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see ARTPolicy + * @see PERange + * @see PERangeList + * @see AvailabilityInfo + * @see ARParallelSpaceShared + * @see ARParallelSpaceShared#handleQueryAvailability(ARMessage) + */ + +public class AvailabilityInfoEntry implements Comparable <AvailabilityInfoEntry> { + + private double time_; + private PERangeList availRanges_; + + /** + * Creates a new instance of {@link AvailabilityInfoEntry} + * @param time the time associated with this entry + */ + public AvailabilityInfoEntry(double time) { + time_ = time; + availRanges_ = null; + } + + /** + * Creates a new instance of {@link AvailabilityInfoEntry} + * @param time the time associated with this entry + * @param ranges the list of ranges of PEs available + */ + public AvailabilityInfoEntry(double time, PERangeList ranges) { + time_ = time; + availRanges_ = ranges; + } + + /** + * Gets the time associated with this entry + * @return the time associated with this entry + */ + public double getTime() { + return time_; + } + + /** + * Sets the time associated with this entry + * @param time the time associated with this entry + * @return <tt>true</tt> if the time has been set successfully or + * <tt>false</tt> otherwise. + */ + public boolean setTime(double time) { + if(time < 0) + return false; + + time_ = time; + return true; + } + + /** + * Returns the list of ranges available at this entry + * @return the list of ranges available + */ + public PERangeList getAvailRanges() { + return availRanges_; + } + + /** + * Sets the ranges of PEs available at this entry + * @param availRanges the list of ranges of PEs available + */ + public void setAvailRanges(PERangeList availRanges) { + availRanges_ = availRanges; + } + + /** + * Compares this object with the specified object for order. + * Returns a negative integer, zero, or a positive integer + * as this object is less than, equal to, or greater + * than the specified object. + * @param entry the entry to be compared. + * @return a negative integer, zero, or a positive integer as + * this entry is less than, equal to, or greater + * than the specified entry. + */ + public int compareTo(AvailabilityInfoEntry entry) { + int result = 0; + if(time_ < entry.time_) { + result = -1; + } + else if(time_ > entry.time_) { + result = 1; + } + return result; + } + + /** + * Gets the number of PEs associated with this entry + * @return the number of PEs + */ + public int getNumPE() { + if(availRanges_ == null) + return 0; + else + return availRanges_.getNumPE(); + } + + /** + * Creates a string representation of this entry + * @return a representation of this entry + */ + public String toString() { + return "{time="+ time_ + "; " + + ( (availRanges_!=null) ? availRanges_ : "{[]}") + "}"; + } +} Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-11-05 01:07:03 UTC (rev 77) @@ -314,7 +314,7 @@ * @pre startTime >= 0 * @pre finishTime > 0 */ - public TimeSlotList queryFreeTime(double startTime, + public AvailabilityInfo queryFreeTime(double startTime, int duration, int resID) { // check all the values first @@ -323,7 +323,7 @@ return null; } - TimeSlotList resOptions = null; + AvailabilityInfo resOptions = null; try { // create the reservation itself Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2007-11-05 01:07:03 UTC (rev 77) @@ -162,7 +162,7 @@ * @pre $none * @post $none */ - public int getUserID() { + public int getSenderID() { return gridlet_.getUserID(); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2007-11-05 01:07:03 UTC (rev 77) @@ -235,7 +235,7 @@ * @pre $none * @post $none */ - public int getUserID() { + public int getSenderID() { if(reservation_==null) return UNKNOWN; @@ -342,7 +342,7 @@ public String toString(int timeUnit) { String unitDesc = getTimeDescr(timeUnit); String result = "Reservation ID: " + reservation_.getID() + "\n" + - "User ID: " + getUserID() + "\n" + + "User ID: " + getSenderID() + "\n" + "Status: " + Reservation.getStatusString(reservation_.getStatus()) + "\n" + "Sub. Time: " + decFormater_.format(convertTime(getSubmissionTime(), timeUnit)) + " " + unitDesc + "\n" + Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2007-11-05 01:07:03 UTC (rev 77) @@ -36,10 +36,10 @@ int getID(); /** - * Returns the id of the user that created this item + * Returns the id of the entity that created this item * @return the user id */ - int getUserID(); + int getSenderID(); /** * Returns the status of this item Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2007-11-05 01:07:03 UTC (rev 77) @@ -111,7 +111,7 @@ // Need to check against the userId as well since each user // might have same Gridlet id submitted to the same GridResource - if (rgl.getID()==gridletId && rgl.getUserID()==userId) { + if (rgl.getID()==gridletId && rgl.getSenderID()==userId) { return rgl; } } Deleted: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java 2007-11-05 01:07:03 UTC (rev 77) @@ -1,129 +0,0 @@ -/* - * 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; - -/** - * The {@link TimeSlotEntry} class represents an entry in a list of - * time slots available, which can be allocated to a user. This is used - * in return to a query for free time slots in an advance reservation - * based allocation policy. - * - * @author Marcos Dias de Assuncao - * @since GridSim Turbo Alpha 0.1 - * - * @see ARTPolicy - * @see PERange - * @see PERangeList - * @see TimeSlotList - * @see ARParallelSpaceShared - * @see ARParallelSpaceShared#handleQueryFreeTime(ARMessage) - */ - -public class TimeSlotEntry implements Comparable <TimeSlotEntry> { - - private double time_; - private PERangeList availRanges_; - - /** - * Creates a new instance of {@link TimeSlotEntry} - * @param time the time associated with this entry - */ - public TimeSlotEntry(double time) { - time_ = time; - availRanges_ = null; - } - - /** - * Creates a new instance of {@link TimeSlotEntry} - * @param time the time associated with this entry - * @param ranges the list of ranges of PEs available - */ - public TimeSlotEntry(double time, PERangeList ranges) { - time_ = time; - availRanges_ = ranges; - } - - /** - * Gets the time associated with this entry - * @return the time associated with this entry - */ - public double getTime() { - return time_; - } - - /** - * Sets the time associated with this entry - * @param time the time associated with this entry - * @return <tt>true</tt> if the time has been set successfully or - * <tt>false</tt> otherwise. - */ - public boolean setTime(double time) { - if(time < 0) - return false; - - time_ = time; - return true; - } - - /** - * Returns the list of ranges available at this entry - * @return the list of ranges available - */ - public PERangeList getAvailRanges() { - return availRanges_; - } - - /** - * Sets the ranges of PEs available at this entry - * @param availRanges the list of ranges of PEs available - */ - public void setAvailRanges(PERangeList availRanges) { - availRanges_ = availRanges; - } - - /** - * Compares this object with the specified object for order. - * Returns a negative integer, zero, or a positive integer - * as this object is less than, equal to, or greater - * than the specified object. - * @param entry the entry to be compared. - * @return a negative integer, zero, or a positive integer as - * this entry is less than, equal to, or greater - * than the specified entry. - */ - public int compareTo(TimeSlotEntry entry) { - int result = 0; - if(time_ < entry.time_) { - result = -1; - } - else if(time_ > entry.time_) { - result = 1; - } - return result; - } - - /** - * Gets the number of PEs associated with this entry - * @return the number of PEs - */ - public int getNumPE() { - if(availRanges_ == null) - return 0; - else - return availRanges_.getNumPE(); - } - - /** - * Creates a string representation of this entry - * @return a representation of this entry - */ - public String toString() { - return "{time="+ time_ + "; " - + ( (availRanges_!=null) ? availRanges_ : "{[]}") + "}"; - } -} Deleted: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java 2007-11-05 01:07:03 UTC (rev 77) @@ -1,314 +0,0 @@ -/* - * 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; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; - -/** - * The {@link TimeSlotList} class represents a list of time slots - * that are available and can be allocated to a user. This is used - * in return to a query for free time slots in an advance reservation - * based allocation policy. - * - * @author Marcos Dias de Assuncao - * @since GridSim Turbo Alpha 0.1 - * - * @see ARTPolicy - * @see PERange - * @see PERangeList - * @see ARParallelSpaceShared - * @see ARParallelSpaceShared#handleQueryFreeTime(ARMessage) - */ - -public class TimeSlotList { - - private static final long serialVersionUID = -3951650752024908016L; - - private ArrayList<TimeSlotEntry> list_; - private double startTime_; - private double finishTime_; - - private static final int UNKNOWN = -1; - - /** - * Default constructor. - */ - public TimeSlotList() { - list_ = new ArrayList<TimeSlotEntry>(); - startTime_ = UNKNOWN; - finishTime_ = UNKNOWN; - } - - /** - * Returns the start time of this list. That is, - * the time of the first element of this list - * @return the start time - */ - public double getStartTime() { - return startTime_; - } - - /** - * Returns the end time of this list. - * @return the end time - */ - public double getEndTime() { - return finishTime_; - } - - /** - * Sets the start time of this list. - * @param startTime the start time - */ - public void setStartTime(double startTime) { - startTime_ = startTime; - } - - /** - * Sets the end time of this list. - * @param finishTime the end time - */ - public void setFinishTime(double finishTime) { - finishTime_ = finishTime; - } - - /** - * Adds the specified element to this list. - * @param entry the entry to be added to this list - * @return <tt>true - */ - public boolean add(TimeSlotEntry entry) { - if(entry == null) { - return false; - } - else { - double entryTime = entry.getTime(); - int size = list_.size(); - int index = 0; - for (index=0; index<size; index++) { - if(list_.get(index).getTime() > entryTime) { - break; - } - } - list_.add(index, entry); - } - return true; - } - - /** - * Adds all of the elements in the specified Collection to this list, - * The behaviour of this operation is undefined if the specified - * Collection is modified while the operation is in progress. - * (This implies that the behaviour of this call is undefined if the - * specified Collection is this list, and this list is nonempty.) - * @param collection the collection to be included in this list - * @return <tt>true<tt> if the collection has been added successfully - * or <tt>false</tt> otherwise. - */ - public boolean addAll(Collection<? extends TimeSlotEntry> collection) { - boolean result = true; - - // adds the collection to the list and sets the start - // and finish time again - if(collection != null && !collection.isEmpty()) { - list_.addAll(collection); - Collections.sort(list_); - } - return result; - } - - /** - * Removes all elements from the list. - */ - public void clear() { - list_.clear(); - } - - /** - * Returns a shallow copy of this list. - * (The elements themselves are not copied.) - */ - public Object clone() { - return list_.clone(); - } - - /** - * Returns <tt>true</tt> if this list contains the specified element. - * @param entry the entry whose presence in this List is to be tested. - * @return <tt>true</tt> if the specified element is present; - * <tt>false</tt> otherwise. - */ - public boolean contains(Object entry) { - return list_.contains(entry); - } - - /** - * Returns the element at the specified position in this list. - * @param index the index of the element to return - * @return the element at the specified position in this list. - */ - public TimeSlotEntry get(int index) { - return list_.get(index); - } - - /** - * Searches for the first occurence of the given argument, - * testing for equality using the equals method. - * @param entry the entry whose index is to be returned - * @return the index of the first occurrence of the argument - * in this list; returns <tt>-1</tt> if the object is not found. - */ - public int indexOf(Object entry) { - return list_.indexOf(entry); - } - - /** - * Tests if this list has no elements. - * @return <tt>true</tt> if the list has no elements. - */ - public boolean isEmpty() { - return list_.isEmpty(); - } - - /** - * Returns an iterator over the elements in this list in proper sequence. - * @return the iterator. - */ - public Iterator<TimeSlotEntry> iterator() { - return list_.iterator(); - } - - /** - * Removes the element at a given index - * @param index the index of the element to be removed - * @return the removed element. - */ - public TimeSlotEntry remove(int index) { - return list_.remove(index); - } - - /** - * Removes a given element from the list. - * @param entry the entry to be removed - * @return <tt>true</tt> if the collection contained the - * specified entry. - */ - public boolean remove(Object entry) { - return list_.remove(entry); - } - - /** - * Returns the size of this list. - * @return the size of this list - */ - public int size() { - return list_.size(); - } - - /** - * Scans the entries in a list and returns the first time frame over - * which a request with the characteristics provided can be scheduled - * @param duration the duration of the request - * @param reqPE the number of PEs required - * @return the start time or <tt>-1</tt> if not found - */ - public double getPotentialStartTime(int duration, int reqPE) { - - // the anchor index, the entry in the profile where - // the request would be placed OR the closest entry to the - // point where the anchor of the request would be placed - int anchorIndex = -1; - - // a pointer to the anchor entry (described above) - TimeSlotEntry anchorEntry = null; - - // the list of selected ranges - PERangeList intersectList = null; - - double potStartTime = -1; // keep the potential start time of the request - double potFinishTime = -1; // store the gridlet's expected finish time - - intersectList = null; - int length = list_.size(); - - Iterator<TimeSlotEntry> iterProfile = list_.iterator(); - while(iterProfile.hasNext()) { - - TimeSlotEntry entry = iterProfile.next(); - anchorEntry = entry; - anchorIndex = list_.indexOf(anchorEntry); - - // sets the start time as the time of the entry - potStartTime = entry.getTime(); - // calculates when the finish time will be if - // the gridlet is put at this position - potFinishTime = potStartTime + duration; - - // scan the profile until an entry with enough PEs is found - if(entry.getNumPE() < reqPE) { - continue; - } - else { - // if an entry with enough PEs is found, then scan the list - // from that point onwards analysing the intersection of - // the ranges available in the entries until the - // request expected completion time - intersectList = entry.getAvailRanges().clone(); - - // Look for the intersection of available ranges from - // the anchor until the end of the profile or until - // the entries are further than the expected completion time - for(int i=anchorIndex+1; i<length; i++){ - TimeSlotEntry nextEntry = list_.get(i); - if(nextEntry.getTime() > potFinishTime){ - break; - } - else{ - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(nextEntry.getTime() < potFinishTime) { - intersectList = PERangeList.intersection(intersectList, - nextEntry.getAvailRanges()); - if(intersectList == null || intersectList.getNumPE() < reqPE) { - break; - } - } - } - } - // If a time slot with enough PEs has been found, then stop the search - if(intersectList != null && intersectList.getNumPE() >= reqPE) { - break; - } - } - } - - // if the potential finish time is larger than the end time of - // this list, then the request cannot be scheduled - if(potFinishTime > finishTime_) { - potStartTime = UNKNOWN; - } - - return potStartTime; - } - - /** - * Creates a string representation of the list - * @return a string representation - */ - public String toString() { - String result = "Availability={\n"; - for(TimeSlotEntry entry : list_){ - result += entry + "\n"; - } - result += "}"; - return result; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |