GridSim 5.0 beta

gridsim.resFailure
Class TimeSharedWithFailure

Object
  extended by Thread
      extended by Sim_entity
          extended by AllocPolicy
              extended by TimeSharedWithFailure
All Implemented Interfaces:
AllocPolicyWithFailure, Cloneable, Runnable

 class TimeSharedWithFailure
extends AllocPolicy
implements AllocPolicyWithFailure

TimeSharedWithFailure class is based on TimeShared, but with added failure functionalities. TimeSharedWithFailure class is an allocation policy for GridResource that behaves similar to a round robin algorithm, except that all Gridlets are executed at the same time. This is a basic and simple scheduler that runs each Gridlet to one Processing Element (PE). If a Gridlet requires more than one PE, then this scheduler only assign this Gridlet to one PE.

Since:
GridSim Toolkit 4.1
Author:
Agustin Caminero
See Also:
TimeShared
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
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
TimeSharedWithFailure(String resourceName, String entityName)
          Allocates a new TimeSharedWithFailure object
 
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 setGridletsFailed()
          Sets the status of all Gridlets in this resource to FAILED.
 void setGridletsFailed(int failedMachID)
          This method is empty because it is not required by this policy.
 
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

TimeSharedWithFailure

TimeSharedWithFailure(String resourceName,
                      String entityName)
                throws Exception
Allocates a new TimeSharedWithFailure object

Parameters:
resourceName - the GridResource entity name that will contain this allocation policy
entityName - this object entity name
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, String[], String[], String)
Pre Condition:
resourceName != null, entityName != null
Post Condition:
$none
Method Detail

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. This method will search the execution and paused list. 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. 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

setGridletsFailed

public void setGridletsFailed()
Sets the status of all Gridlets in this resource to FAILED. Then sends them back to users, and clean up the relevant lists.

Specified by:
setGridletsFailed in interface AllocPolicyWithFailure

setGridletsFailed

public void setGridletsFailed(int failedMachID)
This method is empty because it is not required by this policy. Sets the status of all Gridlets in this machine to FAILED. Then sends them back to users, and clean up the relevant lists.

Specified by:
setGridletsFailed in interface AllocPolicyWithFailure
Parameters:
failedMachID - the id of the failed machine

GridSim 5.0 beta

The University of Melbourne, Australia, 2009