GridSim 5.0 beta

gridsim.parallel.profile
Class PartProfile

Object
  extended by Profile
      extended by PartProfile
All Implemented Interfaces:
Iterable<PartProfileEntry>

public class PartProfile
extends Profile
implements Iterable<PartProfileEntry>

This class represents the profile containing the ranges of PEs available at given simulation times. This class is different from SingleProfile by the fact that it controls the availability at multiple resource partitions.

Since:
5.0
Author:
Marcos Dias de Assuncao
See Also:
Profile, PartProfileEntry, PERangeList, TimeSlot, ResourcePartition

Nested Class Summary
 
Nested classes/interfaces inherited from class Profile
Profile.Entry
 
Field Summary
 
Fields inherited from class Profile
avail
 
Constructor Summary
PartProfile(Collection<ResourcePartition> parts)
          Creates a new PartProfile object.
PartProfile(ResourcePartition[] parts)
          Creates a new PartProfile object.
 
Method Summary
 boolean addPartTimeSlot(int partId, double startTime, double finishTime, PERangeList list)
          Includes a time slot in this availability profile.
 void allocatePartPERanges(int partId, PERangeList selected, double startTime, double finishTime)
          Allocates a list of PE ranges from a partition to a job/reservation and updates the availability profile accordingly.
 ProfileEntry checkPartAvailability(int partId, double startTime, long duration)
          Returns a profile entry if a given job with the characteristics provided can be scheduled.
 ProfileEntry checkPartImmediateAvailability(int partId)
          Returns a profile entry with the currently available PEs at a given partition.
 PartProfile clone()
          Returns a shallow copy of this object.
NOTE: this method does not clone the entries.
 PartProfile copy()
          Returns a copy of this object.
NOTE: this method clones the entries, but does not clone the partition and predicates information.
protected  double currentTime()
          This method returns the current time.
 ProfileEntry findPartStartTime(int partId, int reqPE, long duration)
          Selects an entry able to provide enough PEs to handle a job.
 Collection<TimeSlot> getPartSchedulingOptions(int partId, double startTime, double finishTime, int duration, int reqPEs)
          Returns the scheduling options for a job in a giving partition of this availability profile within the specified period of time.
 Collection<TimeSlot> getPartTimeSlots(int partId, double startTime, double finishTime)
          Returns the time slots contained in a given partition of this availability profile within a specified period of time.
 Iterator<PartProfileEntry> iterator()
          Returns an iterator in case someone needs to iterate this object.
 int matchPartition(ScheduleItem item)
          Returns the ID of the partition whose predicate matches the schedule item provided.
 String toString()
          Creates an string representation of the profile
 
Methods inherited from class Profile
add, allocatePERanges, checkAvailability, checkImmediateAvailability, findStartTime, findStartTime, getPrecedingValue, getSchedulingOptions, getTimeSlots, getTimeSlots, removePastEntries
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PartProfile

public PartProfile(Collection<ResourcePartition> parts)
Creates a new PartProfile object. This constructor receives a collection of ResourcePartition objects which contain the IDs of the partitions and the initial assignments of processing elements.

Parameters:
parts - the collection of resource partitions.
See Also:
ResourcePartition, PartitionPredicate

PartProfile

public PartProfile(ResourcePartition[] parts)
Creates a new PartProfile object. This constructor receives a collection of ResourcePartition objects which contain the IDs of the partitions and the initial assignments of processing elements.

Parameters:
parts - the collection of resource partitions.
See Also:
ResourcePartition, PartitionPredicate
Method Detail

clone

public PartProfile clone()
Returns a shallow copy of this object.
NOTE: this method does not clone the entries.

Overrides:
clone in class Object
Returns:
the cloned object
See Also:
copy()

copy

public PartProfile copy()
Returns a copy of this object.
NOTE: this method clones the entries, but does not clone the partition and predicates information.

Returns:
the copy object

matchPartition

public int matchPartition(ScheduleItem item)
Returns the ID of the partition whose predicate matches the schedule item provided. The method will return -1 if no partition can handle the job/reservation.

Parameters:
item - the item to be scheduled.
Returns:
the partition ID or -1 if no partition can handle the job.

checkPartImmediateAvailability

public ProfileEntry checkPartImmediateAvailability(int partId)
Returns a profile entry with the currently available PEs at a given partition. It does not scan the profile to check if the PEs will be available until the completion of a given job. It just returns an entry with the PEs available right now.

Parameters:
partId - the partition from which the ranges will be obtained
Returns:
a ProfileEntry with the start time equals to the current time and the ranges available at the current time.

checkPartAvailability

public ProfileEntry checkPartAvailability(int partId,
                                          double startTime,
                                          long duration)
Returns a profile entry if a given job with the characteristics provided can be scheduled. It will return null if it is not possible to schedule the job.

Parameters:
partId - the id of the partition in which the job will be scheduled.
startTime - the start time of the job/reservation
duration - the duration of the job/reservation
Returns:
a ProfileEntry with the start time provided and the ranges available at that time + the duration.

findPartStartTime

public ProfileEntry findPartStartTime(int partId,
                                      int reqPE,
                                      long duration)
Selects an entry able to provide enough PEs to handle a job. In this case, the starting time is not provided, so the method iterates the profile until it finds enough PEs for the job, starting from the current simulation time.

Parameters:
partId - the partition in which the job will be scheduled.
reqPE - the number of PEs
duration - the duration in seconds to execute the job
Returns:
an ProfileEntry with the time at which the job can start and the ranges available at that time.

allocatePartPERanges

public void allocatePartPERanges(int partId,
                                 PERangeList selected,
                                 double startTime,
                                 double finishTime)
Allocates a list of PE ranges from a partition to a job/reservation and updates the availability profile accordingly. If the time of the last entry is equals to finish time than another entry is not required. In this case we just increase the number of jobs that rely on that entry to mark either its completion time or start time. The same is valid to the anchor entry, that is the entry that represents the job's start time.

Parameters:
partId - the partition in which the job will be scheduled.
selected - the list of PE ranges selected
startTime - the start time of the job/reservation
finishTime - the finish time of the job/reservation
See Also:
PERangeList

getPartTimeSlots

public Collection<TimeSlot> getPartTimeSlots(int partId,
                                             double startTime,
                                             double finishTime)
Returns the time slots contained in a given partition of this availability profile within a specified period of time.
NOTE: The time slots returned by this method do not overlap. That is, they are not the scheduling options of a given job. They are the windows of availability. Also, they are sorted by start time. For example, obtaining the free time slots of partition 0 of the scheduling queue below will result in time slots 1, 3 and 3:

| | |------------------ | | Part. 1 | Job 5 | P | | E |===================================== s | Job 3 | Time Slot 3 | |------------------------------------- | Job 2 | Time Slot 2 | Part. 0 |------------------------------------- | Job 1 | Time Slot 1 | Job 4 | +------------------------------------- Start Time Finish Time Time

Parameters:
partId - the partition from which the time slots are obtained.
startTime - the start time of the period.
finishTime - the finish time of the period.
Returns:
a collection with the time slots contained in the given partition of the this availability information object within a specified period of time.

getPartSchedulingOptions

public Collection<TimeSlot> getPartSchedulingOptions(int partId,
                                                     double startTime,
                                                     double finishTime,
                                                     int duration,
                                                     int reqPEs)
Returns the scheduling options for a job in a giving partition of this availability profile within the specified period of time. NOTE: In contrast to getPartTimeSlots(int, double, double), the time slots returned by this method OVERLAP because they are the scheduling options for jobs.

Parameters:
partId - the id of the partition from which the scheduling options will be obtained.
startTime - the start time of the period.
finishTime - the finish time of the period.
duration - the minimum duration of the free time slots. Free time slots whose time frames are smaller than duration will be ignored. If you choose 1, then all scheduling options will be returned.
reqPEs - the minimum number of PEs of the free time slots. Free time slots whose numbers of PEs are smaller than numPEs will be ignored. If you choose 1, then all scheduling options will be returned.
Returns:
a collection with the time scheduling options in this availability information object within the specified period of time.

addPartTimeSlot

public boolean addPartTimeSlot(int partId,
                               double startTime,
                               double finishTime,
                               PERangeList list)
Includes a time slot in this availability profile. This is useful if your scheduling strategy cancels a job and you want to update the availability profile.

Parameters:
partId - the partition to which the time slot will be added.
startTime - the start time of the time slot.
finishTime - the finish time of the time slot.
list - the list of ranges of PEs in the slot.
Returns:
true if the slot was included; false otherwise.

toString

public String toString()
Creates an string representation of the profile

Overrides:
toString in class Profile
Returns:
an string representation

iterator

public Iterator<PartProfileEntry> iterator()
Returns an iterator in case someone needs to iterate this object.
NOTE: Removing objects from this profile via its iterator may make it behave in an unexpected way.

Specified by:
iterator in interface Iterable<PartProfileEntry>
Returns:
an iterator for the SingleProfileEntry objects in this profile.

currentTime

protected double currentTime()
This method returns the current time.

Specified by:
currentTime in class Profile
Returns:
the current time.
See Also:
Profile.currentTime()

GridSim 5.0 beta

The University of Melbourne, Australia, 2009