GridSim 5.0 beta

gridsim.parallel.profile
Class Profile

Object
  extended by Profile
Direct Known Subclasses:
PartProfile, SingleProfile

public abstract class Profile
extends Object

This class represents the profile containing the ranges of PEs available at given simulation times.

Since:
5.0
Author:
Marcos Dias de Assuncao

Nested Class Summary
protected  class Profile.Entry
          This class is used to return an entry when the user calls one of the methods to query the availability of resources.
 
Field Summary
protected  LinkedTreeMap<Double,ProfileEntry> avail
           
 
Constructor Summary
protected Profile()
          Protected constructor.
protected Profile(LinkedTreeMap<Double,ProfileEntry> avail)
          Protected constructor used by the cloning operations.
 
Method Summary
protected  ProfileEntry add(ProfileEntry entry)
          Adds an entry to the availability profile.
 void allocatePERanges(PERangeList selected, double startTime, double finishTime)
          Allocates a list of PE ranges to a job/reservation.
 ProfileEntry checkAvailability(int reqPE, double startTime, long duration)
          Returns a profile entry if a given job with the characteristics provided can be scheduled.
 ProfileEntry checkImmediateAvailability()
          Returns a profile entry with the currently available PEs.
protected abstract  double currentTime()
          This method returns the current time (or simulation time if the data structure is used for simulation purposes.
 ProfileEntry findStartTime(int reqPE, double readyTime, long duration)
          Selects an entry able to provide enough PEs to handle a job.
 ProfileEntry findStartTime(int reqPE, long duration)
          Selects an entry able to provide enough PEs to handle a job.
protected  ProfileEntry getPrecedingValue(double time)
          Returns the entry whose time is closest to the time given but smaller, or whose time is equals to time
 Collection<TimeSlot> getSchedulingOptions(double startTime, double finishTime, int duration, int reqPEs)
          Returns the scheduling options of this availability profile within the specified period of time.
protected  Collection<TimeSlot> getTimeSlots(double finishTime, ArrayList<Profile.Entry> subProfile)
          A helper method which actually does the real job for getTimeSlots(double, double).
 Collection<TimeSlot> getTimeSlots(double startTime, double finishTime)
          Returns the time slots contained in this availability profile within a specified period of time.
 void removePastEntries(double refTime)
          Removes past entries from the availability profile, but keeps the entry corresponding to the reference time provided, or the entry preceding it if an entry with the provided time does not exist.
 String toString()
          Creates an string representation of the profile
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

avail

protected LinkedTreeMap<Double,ProfileEntry> avail
Constructor Detail

Profile

protected Profile()
Protected constructor.


Profile

protected Profile(LinkedTreeMap<Double,ProfileEntry> avail)
Protected constructor used by the cloning operations.

Parameters:
avail - the availability information map.
See Also:
ProfileEntry
Method Detail

currentTime

protected abstract double currentTime()
This method returns the current time (or simulation time if the data structure is used for simulation purposes.

Returns:
the current time.

removePastEntries

public void removePastEntries(double refTime)
Removes past entries from the availability profile, but keeps the entry corresponding to the reference time provided, or the entry preceding it if an entry with the provided time does not exist. NOTE: If refTime is greater than the simulation time, then the method will consider the current simulation time as refTime.

Parameters:
refTime - the reference time for removing the entries.

checkImmediateAvailability

public ProfileEntry checkImmediateAvailability()
Returns a profile entry with the currently available PEs.

Returns:
a ProfileEntry with the start time equals to the current time and the ranges available at the current time.

checkAvailability

public ProfileEntry checkAvailability(int reqPE,
                                      double startTime,
                                      long duration)
Returns a profile entry if a given job with the characteristics provided can be scheduled.

Parameters:
reqPE - the number of PEs.
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 OR null if not enough PEs are found.

findStartTime

public ProfileEntry findStartTime(int reqPE,
                                  double readyTime,
                                  long duration)
Selects an entry able to provide enough PEs to handle a job. The method iterates the profile until it finds enough PEs for the job, starting from the current simulation time.

Parameters:
reqPE - the number of PEs
readyTime - entries prior to ready time will not be considered
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.

findStartTime

public ProfileEntry findStartTime(int reqPE,
                                  long duration)
Selects an entry able to provide enough PEs to handle a job. The method iterates the profile until it finds enough PEs for the job, starting from the current simulation time.

Parameters:
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.

allocatePERanges

public void allocatePERanges(PERangeList selected,
                             double startTime,
                             double finishTime)
Allocates a list of PE ranges to a job/reservation.

Parameters:
selected - the list of PE ranges selected
startTime - the start time of the job/reservation
finishTime - the finish time of the job/reservation

getTimeSlots

public Collection<TimeSlot> getTimeSlots(double startTime,
                                         double finishTime)
Returns the time slots contained in 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:

|------------------------------------- | Job 3 | Time Slot 3 | P |------------------------------------- E | Job 2 | Time Slot 2 | s |------------------------------------- | Job 1 | Time Slot 1 | Job 4 | +------------------------------------- Start Time Finish Time Time

Parameters:
startTime - the start time of the period.
finishTime - the finish time of the period.
Returns:
a collection with the time slots.
See Also:
TimeSlot

getSchedulingOptions

public Collection<TimeSlot> getSchedulingOptions(double startTime,
                                                 double finishTime,
                                                 int duration,
                                                 int reqPEs)
Returns the scheduling options of this availability profile within the specified period of time. NOTE: The time slots returned by this method OVERLAP because they are the scheduling options for jobs.

Parameters:
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.
See Also:
TimeSlot

toString

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

Overrides:
toString in class Object
Returns:
an string representation

add

protected ProfileEntry add(ProfileEntry entry)
Adds an entry to the availability profile.

Parameters:
entry - the entry to be removed.
Returns:
the entry replaced by the new entry or null if no entry was replaced.

getPrecedingValue

protected ProfileEntry getPrecedingValue(double time)
Returns the entry whose time is closest to the time given but smaller, or whose time is equals to time

Parameters:
time - the time to be used to search for the entry
Returns:
the entry whose time is closest to the time given but smaller, or whose time is equals to time; null if not found.

getTimeSlots

protected Collection<TimeSlot> getTimeSlots(double finishTime,
                                            ArrayList<Profile.Entry> subProfile)
A helper method which actually does the real job for getTimeSlots(double, double).

Parameters:
finishTime - the finish time of the period.
subProfile - the profile already cloned and cut from start time and finish time.
Returns:
a collection with the time slots.

GridSim 5.0 beta

The University of Melbourne, Australia, 2009