GridSim 5.0 beta

gridsim
Class ARSimpleSpaceShared

Object
  extended by Thread
      extended by Sim_entity
          extended by AllocPolicy
              extended by ARPolicy
                  extended by ARSimpleSpaceShared
All Implemented Interfaces:
Cloneable, Runnable

public class ARSimpleSpaceShared
extends ARPolicy

This is a resource scheduler that handles Advanced Reservation functionalities. This scheduler is also able to handle submitted jobs without reserving in the first place.

As this class name suggested, this scheduler is only able to handle some basic AR functionalities, such as:

There are some limitations on this scheduler:

Since:
GridSim Toolkit 3.0
Author:
Anthony Sulistio
See Also:
GridSim, ResourceCharacteristics
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class ARPolicy
MILLI_SEC
 
Fields inherited from class AllocPolicy
initTime_, myId_, outputPort_, resCalendar_, resId_, resName_, resource_, totalPE_
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ARSimpleSpaceShared(String resourceName, String entityName)
          Creates a new scheduler that handles advanced reservations.
ARSimpleSpaceShared(String resourceName, String entityName, int commitPeriod)
          Creates a new scheduler that handles advanced reservations.
 
Method Summary
 void body()
          Handles internal events that are coming to this entity.
 void gridletCancel(int gridletId, int userId)
          Cancels a Gridlet running in this entity.
 void gridletMove(int gridletId, int userId, int destId, boolean ack)
          Moves a Gridlet from this GridResource entity to a different one.
 void gridletPause(int gridletId, int userId, boolean ack)
          Pauses a Gridlet only if it is currently executing.
 void gridletResume(int gridletId, int userId, boolean ack)
          Resumes a Gridlet only in the paused list.
 int gridletStatus(int gridletId, int userId)
          Finds the status of a specified Gridlet ID.
 void gridletSubmit(Gridlet gl, boolean ack)
          Schedules a new Gridlet that has been received by the GridResource entity.
 void handleCancelReservation(int reservationID, int senderID, ArrayList list, int sendTag)
          Handles a cancel reservation request for a given Gridlet ID list.
 void handleCancelReservation(int reservationID, int senderID, int sendTag)
          Handles a cancel reservation request.
 void handleCancelReservation(int reservationID, int senderID, int gridletID, int sendTag)
          Handles a cancel reservation request.
 void handleCommitOnly(int reservationID, int senderID, int sendTag)
          Handles a commit reservation request.
 void handleCommitReservation(int reservationID, int senderID, int sendTag, Gridlet gridlet)
          Handles a commit reservation request.
 void handleCommitReservation(int reservationID, int senderID, int sendTag, GridletList list)
          Handles a commit reservation request.
 void handleCreateReservation(ARObject obj, int senderID, int sendTag)
          Handles an advanced reservation request.
 void handleImmediateReservation(ARObject obj, int senderID, int sendTag)
          Handles an immediate reservation request.
NOTE: currently able to handle a case where start time = 0 and duration or end time > 0.
 void handleModifyReservation(ARObject obj, int senderID, int sendTag)
          Handles a modify reservation request (NOTE: NOT YET SUPPORTED).
 void handleQueryBusyTime(long from, long to, int senderID, int sendTag, double userTimeZone)
          Handles a query busy time request (NOTE: NOT YET SUPPORTED).
 void handleQueryFreeTime(long from, long to, int senderID, int sendTag, double userTimeZone)
          Handles a query free time request (NOTE: NOT YET SUPPORTED).
 void handleQueryReservation(int reservationID, int senderID, int sendTag)
          Handles a query reservation request.
 
Methods inherited from class ARPolicy
approxBusyTime, getCurrentTime, replyCancelReservation, replyCommitReservation, replyCreateReservation, replyModifyReservation, replyQueryReservation, replyTimeReservation, searchReservation
 
Methods inherited from class AllocPolicy
addTotalLoad, calculateTotalLoad, findGridlet, getTotalLoad, gridletMigrate, init, isEndSimulation, processOtherEvent, sendAck, sendCancelGridlet, sendFinishGridlet, sendInternalEvent, sendInternalEvent, setEndSimulation
 
Methods inherited from class Sim_entity
add_generator, add_param, add_port, clone, get_id, get_name, get_port, get_port, get_stat, run, send_on, set_invisible, set_stat, sim_cancel, sim_completed, sim_current, sim_get_next, sim_get_next, sim_hold_for, sim_hold, sim_pause_for, sim_pause_for, sim_pause_until, sim_pause_until, sim_pause, sim_process_for, sim_process_for, sim_process_until, sim_process_until, sim_process, sim_putback, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_schedule, sim_select, sim_trace, sim_wait_for, sim_wait_for, sim_wait_for, sim_wait, sim_waiting, sim_waiting
 
Methods inherited from class Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ARSimpleSpaceShared

public ARSimpleSpaceShared(String resourceName,
                           String entityName)
                    throws Exception
Creates a new scheduler that handles advanced reservations. This scheduler uses First Come First Serve (FCFS) algorithm. A default commit period time for a user to commit a reservation is set to 30 minutes.

Parameters:
resourceName - the GridResource entity name that will contain this allocation policy
entityName - this object name. The name of this entity will be "resourceName_entityName".
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean), GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
resourceName != null, entityName != null
Post Condition:
$none

ARSimpleSpaceShared

public ARSimpleSpaceShared(String resourceName,
                           String entityName,
                           int commitPeriod)
                    throws Exception
Creates a new scheduler that handles advanced reservations. This scheduler uses First Come First Serve (FCFS) algorithm.

Parameters:
resourceName - the GridResource entity name that will contain this allocation policy
entityName - this object name. The name of this entity will be "resourceName_entityName".
commitPeriod - a default commit period time for a user to commit a reservation (unit is in second). NOTE: once it is set, you can not change the time again.
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean), GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
resourceName != null, entityName != null
Post Condition:
$none
Method Detail

handleModifyReservation

public void handleModifyReservation(ARObject obj,
                                    int senderID,
                                    int sendTag)
Handles a modify reservation request (NOTE: NOT YET SUPPORTED).

Specified by:
handleModifyReservation in class ARPolicy
Parameters:
obj - a reservation object
senderID - a sender or user ID
sendTag - a tag to send to the user
Pre Condition:
obj != null, senderID > 0
Post Condition:
$none

handleImmediateReservation

public void handleImmediateReservation(ARObject obj,
                                       int senderID,
                                       int sendTag)
Handles an immediate reservation request.
NOTE:

Specified by:
handleImmediateReservation in class ARPolicy
Parameters:
obj - a reservation object
senderID - a sender or user ID
sendTag - a tag to send the result back to user
Pre Condition:
obj != null, senderID > 0
Post Condition:
$none

handleCreateReservation

public void handleCreateReservation(ARObject obj,
                                    int senderID,
                                    int sendTag)
Handles an advanced reservation request.

Specified by:
handleCreateReservation in class ARPolicy
Parameters:
obj - a reservation object
senderID - a sender or user ID
sendTag - a tag to send the result back to user
Pre Condition:
obj != null, senderID > 0
Post Condition:
$none

handleCancelReservation

public void handleCancelReservation(int reservationID,
                                    int senderID,
                                    ArrayList list,
                                    int sendTag)
Handles a cancel reservation request for a given Gridlet ID list.

Specified by:
handleCancelReservation in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender ID
list - a list of Gridlet IDs
sendTag - a tag to send the result back to user
Pre Condition:
reservationID > 0, senderID > 0, list != null
Post Condition:
$none

handleCancelReservation

public void handleCancelReservation(int reservationID,
                                    int senderID,
                                    int sendTag)
Handles a cancel reservation request. All Gridlets will be cancelled.

Specified by:
handleCancelReservation in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender ID
sendTag - a tag to send the result back to user
Pre Condition:
reservationID > 0, senderID > 0
Post Condition:
$none

handleCancelReservation

public void handleCancelReservation(int reservationID,
                                    int senderID,
                                    int gridletID,
                                    int sendTag)
Handles a cancel reservation request. This method cancels only for a given Gridlet ID of a reservation.

Specified by:
handleCancelReservation in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender ID
gridletID - a Gridlet ID
sendTag - a tag to send the result back to user
Pre Condition:
reservationID > 0, senderID > 0
Post Condition:
$none

handleQueryBusyTime

public void handleQueryBusyTime(long from,
                                long to,
                                int senderID,
                                int sendTag,
                                double userTimeZone)
Handles a query busy time request (NOTE: NOT YET SUPPORTED).

Specified by:
handleQueryBusyTime in class ARPolicy
Parameters:
from - starting period time
to - ending period time
senderID - a sender or user ID
sendTag - a tag to send to the user
Pre Condition:
from > 0, to > 0, senderID > 0
Post Condition:
$none

handleQueryFreeTime

public void handleQueryFreeTime(long from,
                                long to,
                                int senderID,
                                int sendTag,
                                double userTimeZone)
Handles a query free time request (NOTE: NOT YET SUPPORTED).

Specified by:
handleQueryFreeTime in class ARPolicy
Parameters:
from - starting period time
to - ending period time
senderID - a sender or user ID
sendTag - a tag to send to the user
Pre Condition:
from > 0, to > 0, senderID > 0
Post Condition:
$none

handleCommitOnly

public void handleCommitOnly(int reservationID,
                             int senderID,
                             int sendTag)
Handles a commit reservation request. This method commits a reservation only. Gridlets are submitted using handleCommitReservation(int, int, int, Gridlet) or handleCommitReservation(int, int, int, GridletList) method.

Specified by:
handleCommitOnly in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender or user ID
sendTag - a tag to send to the user
Pre Condition:
reservationID > 0, senderID > 0
Post Condition:
$none

handleCommitReservation

public void handleCommitReservation(int reservationID,
                                    int senderID,
                                    int sendTag,
                                    GridletList list)
Handles a commit reservation request. This method commits a reservation and submits a Gridlet to be processed as well.

Specified by:
handleCommitReservation in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender or user ID
sendTag - a tag to send to the user
list - a list of Gridlet object
Pre Condition:
reservationID > 0, senderID > 0, list != null
Post Condition:
$none

handleCommitReservation

public void handleCommitReservation(int reservationID,
                                    int senderID,
                                    int sendTag,
                                    Gridlet gridlet)
Handles a commit reservation request. This method commits a reservation and submits a list of Gridlets to be processed as well.

Specified by:
handleCommitReservation in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender or user ID
sendTag - a tag to send to the user
gridlet - a Gridlet object
Pre Condition:
reservationID > 0, senderID > 0, gridlet != null
Post Condition:
$none

handleQueryReservation

public void handleQueryReservation(int reservationID,
                                   int senderID,
                                   int sendTag)
Handles a query reservation request.

Specified by:
handleQueryReservation in class ARPolicy
Parameters:
reservationID - a reservation ID
senderID - a sender or user ID
sendTag - a tag to send to the user
Pre Condition:
reservationID > 0, senderID > 0
Post Condition:
$none

body

public void body()
Handles internal events that are coming to this entity.

Overrides:
body in class Sim_entity
Pre Condition:
$none
Post Condition:
$none

gridletSubmit

public void gridletSubmit(Gridlet gl,
                          boolean ack)
Schedules a new Gridlet that has been received by the GridResource entity.

Specified by:
gridletSubmit in class AllocPolicy
Parameters:
gl - a Gridlet object that is going to be executed
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
See Also:
ResGridlet, ResGridletList
Pre Condition:
gl != null
Post Condition:
$none

gridletStatus

public int gridletStatus(int gridletId,
                         int userId)
Finds the status of a specified Gridlet ID.

Specified by:
gridletStatus in class AllocPolicy
Parameters:
gridletId - a Gridlet ID
userId - the user or owner's ID of this Gridlet
Returns:
the Gridlet status or -1 if not found
See Also:
Gridlet
Pre Condition:
gridletId > 0, userId > 0
Post Condition:
$none

gridletCancel

public void gridletCancel(int gridletId,
                          int userId)
Cancels a Gridlet running in this entity. The User ID is important as many users might have the same Gridlet ID in the lists.
NOTE:

Specified by:
gridletCancel in class AllocPolicy
Parameters:
gridletId - a Gridlet ID
userId - the user or owner's ID of this Gridlet
Pre Condition:
gridletId > 0, userId > 0
Post Condition:
$none

gridletPause

public void gridletPause(int gridletId,
                         int userId,
                         boolean ack)
Pauses a Gridlet only if it is currently executing. This method will search in the execution list, as well as in the queue list. The User ID is important as many users might have the same Gridlet ID in the lists.

Specified by:
gridletPause in class AllocPolicy
Parameters:
gridletId - a Gridlet ID
userId - the user or owner's ID of this Gridlet
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
Pre Condition:
gridletId > 0, userId > 0
Post Condition:
$none

gridletMove

public void gridletMove(int gridletId,
                        int userId,
                        int destId,
                        boolean ack)
Moves a Gridlet from this GridResource entity to a different one. This method will search in both the execution and paused list. The User ID is important as many Users might have the same Gridlet ID in the lists.

If a Gridlet has finished beforehand, then this method will send back the Gridlet to sender, i.e. the userId and sets the acknowledgment to false (if required).

Specified by:
gridletMove in class AllocPolicy
Parameters:
gridletId - a Gridlet ID
userId - the user or owner's ID of this Gridlet
destId - a new destination GridResource ID for this Gridlet
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
Pre Condition:
gridletId > 0, userId > 0, destId > 0
Post Condition:
$none

gridletResume

public void gridletResume(int gridletId,
                          int userId,
                          boolean ack)
Resumes a Gridlet only in the paused list. The User ID is important as many Users might have the same Gridlet ID in the lists.

Specified by:
gridletResume in class AllocPolicy
Parameters:
gridletId - a Gridlet ID
userId - the user or owner's ID of this Gridlet
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
Pre Condition:
gridletId > 0, userId > 0
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009