GridSim 5.0 beta

gridsim
Class Gridlet

Object
  extended by Gridlet
Direct Known Subclasses:
DataGridlet

public class Gridlet
extends Object

A Gridlet is a package that contains all the information related to the job and its execution management details such as job length expressed in MI (Millions Instruction), the size of input and output files, and the job owner id. Individual users model their application by creating Gridlets for processing them on Grid resources.

These basic parameters help in determining execution time, the time required to transport input and output files between users and remote resources, and returning the processed Gridlets back to the originator along with the results.

For a Gridlet that requires many Processing Elements (PEs) or CPUs, the gridlet length is calculated only for 1 PE for simplicity.
For example, this Gridlet has a length of 500 MI and requires 2 PEs. This means each PE will execute 500 MI of this Gridlet.

From GridSim 3.1, we have also added a classType attribute which can be used to provide differentiated service to scheduling gridlets on a resource. The higher the classType means the higher the priority of scheduling this Gridlet on the resource. However, it is up to the resource's allocation policy to schedule gridlets based on their priority or not.

By default, this object records a history of every activity, such as when this Gridlet is being put into a queue, and when it is being executed by a resource. You can find the history by using getGridletHistory().
However, this approach requires a significant amount of memory if you have many Gridlet objects. To disable this functionality, use Gridlet(int, double, long, long, boolean) constructor instead.

Since:
GridSim Toolkit 1.0
Author:
Manzur Murshed and Rajkumar Buyya, Anthony Sulistio
Invariant:
$none

Field Summary
static int CANCELED
          The Gridlet has been canceled.
static int CREATED
          The Gridlet has been created and added to the GridletList object
static int FAILED
          The Gridlet is failed
static int FAILED_RESOURCE_UNAVAILABLE
          The gridlet has failed due to a resource failure
static int INEXEC
          The Gridlet is in execution in a Grid node
static int PAUSED
          The Gridlet has been paused.
static int QUEUED
          The Gridlet has moved to a Grid node
static int READY
          The Gridlet has been assigned to a GridResource object as planned
static int RESUMED
          The Gridlet has been resumed from PAUSED state.
static int SUCCESS
          The Gridlet has been executed successfully
 
Constructor Summary
Gridlet(int gridletID, double gridletLength, long gridletFileSize, long gridletOutputSize)
          Allocates a new Gridlet object.
Gridlet(int gridletID, double gridletLength, long gridletFileSize, long gridletOutputSize, boolean record)
          Allocates a new Gridlet object.
Gridlet(int gridletID, double gridletLength, long gridletFileSize, long gridletOutputSize, int classType)
          Allocates a new Gridlet object.
 
Method Summary
 double getActualCPUTime()
          Gets the total execution time of this Gridlet from the latest GridResource
 double getActualCPUTime(int resId)
          Gets the total execution time of this Gridlet in a given GridResource ID
 int[] getAllResourceID()
          Gets all the GridResource IDs that executed this Gridlet
 String[] getAllResourceName()
          Gets all the GridResource names that executed this Gridlet
 int getClassType()
          Gets the classtype or priority of this Gridlet for scheduling on a resource.
 double getCostPerSec()
          Gets the cost running this Gridlet in the latest GridResource
 double getCostPerSec(int resId)
          Gets the cost running this Gridlet in a given GridResource ID
 double getExecStartTime()
          Gets the latest execution start time
 double getFinishTime()
          Gets the finish time of this Gridlet in a GridResource
 long getGridletFileSize()
          Gets the input file size of this Gridlet BEFORE submitting to a GridResource
 double getGridletFinishedSoFar()
          Gets the length of this Gridlet that has been executed so far from the latest GridResource.
 double getGridletFinishedSoFar(int resId)
          Gets the length of this Gridlet that has been executed so far in a given GridResource ID.
 String getGridletHistory()
          Gets the history of this Gridlet.
 int getGridletID()
          Gets the Gridlet ID
 double getGridletLength()
          Gets the length of this Gridlet
 long getGridletOutputSize()
          Gets the output size of this Gridlet AFTER submitting and executing to a GridResource
 int getGridletStatus()
          Gets the status code of this Gridlet
 String getGridletStatusString()
          Gets the string representation of the current Gridlet status code
 int getNetServiceLevel()
          Gets the network service level for sending this gridlet over a network
 int getNumPE()
          Gets the number of PEs required to run this Gridlet
 double getProcessingCost()
          Gets the total cost of processing or executing this Gridlet Processing Cost = actual CPU Time * cost per sec
 int getReservationID()
          Gets the reservation ID that owns this Gridlet
 int getResourceID()
          Gets the latest resource ID that processes this Gridlet
 String getResourceName(int resId)
          Gets the GridResource name based on its ID
static String getStatusString(int status)
          Gets the string representation of the given Gridlet status code
 double getSubmissionTime()
          Gets the submission or arrival time of this Gridlet from the latest GridResource
 double getSubmissionTime(int resId)
          Gets the submission or arrival time of this Gridlet in the given GridResource ID
 int getUserID()
          Gets the user or owner ID of this Gridlet
 double getWaitingTime()
          Gets the waiting time of this gridlet executed on a resource
 double getWallClockTime()
          Gets the time of this Gridlet resides in the latest GridResource (from arrival time until departure time).
 double getWallClockTime(int resId)
          Gets the time of this Gridlet resides in a given GridResource ID (from arrival time until departure time).
 boolean hasReserved()
          Checks whether this Gridlet is submitted by reserving or not.
 boolean isFinished()
          Checks whether this Gridlet has finished execution or not
 boolean setClassType(int classType)
          Sets the classType or priority of this Gridlet for scheduling on a resource.
 void setExecParam(double wallTime, double actualTime)
          Sets this Gridlet's execution parameters.
 void setExecStartTime(double clockTime)
          Sets the execution start time of this Gridlet inside a GridResource.
 void setGridletFinishedSoFar(double length)
          Sets the length of this Gridlet that has been executed so far.
 boolean setGridletLength(double gridletLength)
          Sets the length or size (in MI) of this Gridlet to be executed in a GridResource.
 void setGridletStatus(int newStatus)
          Sets the status code of this Gridlet
 boolean setNetServiceLevel(int netServiceLevel)
          Sets the network service level for sending this gridlet over a network
 boolean setNumPE(int numPE)
          Sets the number of PEs required to run this Gridlet.
 boolean setReservationID(int resId)
          Sets the id of the reservation made for this gridlet
 void setResourceParameter(int resourceID, double cost)
          Sets the resource parameters for which this Gridlet is going to be executed.
 void setSubmissionTime(double clockTime)
          Sets the submission or arrival time of this Gridlet into a GridResource
 void setUserID(int id)
          Sets the user or owner ID of this Gridlet.
protected  void write(String str)
          Writes this particular history transaction of this Gridlet into a log
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATED

public static final int CREATED
The Gridlet has been created and added to the GridletList object

See Also:
Constant Field Values

READY

public static final int READY
The Gridlet has been assigned to a GridResource object as planned

See Also:
Constant Field Values

QUEUED

public static final int QUEUED
The Gridlet has moved to a Grid node

See Also:
Constant Field Values

INEXEC

public static final int INEXEC
The Gridlet is in execution in a Grid node

See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
The Gridlet has been executed successfully

See Also:
Constant Field Values

FAILED

public static final int FAILED
The Gridlet is failed

See Also:
Constant Field Values

CANCELED

public static final int CANCELED
The Gridlet has been canceled.

See Also:
Constant Field Values

PAUSED

public static final int PAUSED
The Gridlet has been paused. It can be resumed by changing the status into RESUMED.

See Also:
Constant Field Values

RESUMED

public static final int RESUMED
The Gridlet has been resumed from PAUSED state.

See Also:
Constant Field Values

FAILED_RESOURCE_UNAVAILABLE

public static final int FAILED_RESOURCE_UNAVAILABLE
The gridlet has failed due to a resource failure

See Also:
Constant Field Values
Constructor Detail

Gridlet

public Gridlet(int gridletID,
               double gridletLength,
               long gridletFileSize,
               long gridletOutputSize,
               int classType)
Allocates a new Gridlet object. The Gridlet length, input and output file sizes should be greater than or equal to 1. By default, this constructor records the history of this object.

Parameters:
gridletID - the unique ID of this Gridlet
gridletLength - the length or size (in MI) of this Gridlet to be executed in a GridResource
gridletFileSize - the file size (in byte) of this Gridlet BEFORE submitting to a GridResource
gridletOutputSize - the file size (in byte) of this Gridlet AFTER finish executing by a GridResource
classType - Sets the class type or priority of this gridlet for scheduling on a resource.
Pre Condition:
gridletID >= 0, gridletLength >= 0.0, gridletFileSize >= 1, gridletOutputSize >= 1
Post Condition:
$none

Gridlet

public Gridlet(int gridletID,
               double gridletLength,
               long gridletFileSize,
               long gridletOutputSize,
               boolean record)
Allocates a new Gridlet object. The Gridlet length, input and output file sizes should be greater than or equal to 1.

Parameters:
gridletID - the unique ID of this Gridlet
gridletLength - the length or size (in MI) of this Gridlet to be executed in a GridResource
gridletFileSize - the file size (in byte) of this Gridlet BEFORE submitting to a GridResource
gridletOutputSize - the file size (in byte) of this Gridlet AFTER finish executing by a GridResource
record - record the history of this object or not
Pre Condition:
gridletID >= 0, gridletLength >= 0.0, gridletFileSize >= 1, gridletOutputSize >= 1
Post Condition:
$none

Gridlet

public Gridlet(int gridletID,
               double gridletLength,
               long gridletFileSize,
               long gridletOutputSize)
Allocates a new Gridlet object. The Gridlet length, input and output file sizes should be greater than or equal to 1. By default this constructor sets the history of this object.

Parameters:
gridletID - the unique ID of this Gridlet
gridletLength - the length or size (in MI) of this Gridlet to be executed in a GridResource
gridletFileSize - the file size (in byte) of this Gridlet BEFORE submitting to a GridResource
gridletOutputSize - the file size (in byte) of this Gridlet AFTER finish executing by a GridResource
Pre Condition:
gridletID >= 0, gridletLength >= 0.0, gridletFileSize >= 1, gridletOutputSize >= 1
Post Condition:
$none
Method Detail

setReservationID

public boolean setReservationID(int resId)
Sets the id of the reservation made for this gridlet

Parameters:
resId - the reservation ID
Returns:
true if the ID has successfully been set or false otherwise.

getReservationID

public int getReservationID()
Gets the reservation ID that owns this Gridlet

Returns:
a reservation ID
Pre Condition:
$none
Post Condition:
$none

hasReserved

public boolean hasReserved()
Checks whether this Gridlet is submitted by reserving or not.

Returns:
true if this Gridlet has reserved before, false otherwise

setGridletLength

public boolean setGridletLength(double gridletLength)
Sets the length or size (in MI) of this Gridlet to be executed in a GridResource. This Gridlet length is calculated for 1 PE only not the total length.

Parameters:
gridletLength - the length or size (in MI) of this Gridlet to be executed in a GridResource
Returns:
true if it is successful, false otherwise
Pre Condition:
gridletLength > 0
Post Condition:
$none

setNetServiceLevel

public boolean setNetServiceLevel(int netServiceLevel)
Sets the network service level for sending this gridlet over a network

Parameters:
netServiceLevel - determines the kind of service this gridlet receives in the network (applicable to selected PacketScheduler class only)
Returns:
true if successful.
Pre Condition:
netServiceLevel >= 0
Post Condition:
$none

getNetServiceLevel

public int getNetServiceLevel()
Gets the network service level for sending this gridlet over a network

Returns:
the network service level
Pre Condition:
$none
Post Condition:
$none

getWaitingTime

public double getWaitingTime()
Gets the waiting time of this gridlet executed on a resource

Returns:
the waiting time
Pre Condition:
$none
Post Condition:
$none

setClassType

public boolean setClassType(int classType)
Sets the classType or priority of this Gridlet for scheduling on a resource.

Parameters:
classType - classType of this Gridlet
Returns:
true if it is successful, false otherwise
Pre Condition:
classType > 0
Post Condition:
$none

getClassType

public int getClassType()
Gets the classtype or priority of this Gridlet for scheduling on a resource.

Returns:
classtype of this gridlet
Pre Condition:
$none
Post Condition:
$none

setNumPE

public boolean setNumPE(int numPE)
Sets the number of PEs required to run this Gridlet.
NOTE: The Gridlet length is computed only for 1 PE for simplicity.
For example, this Gridlet has a length of 500 MI and requires 2 PEs. This means each PE will execute 500 MI of this Gridlet.

Parameters:
numPE - number of PE
Returns:
true if it is successful, false otherwise
Pre Condition:
numPE > 0
Post Condition:
$none

getNumPE

public int getNumPE()
Gets the number of PEs required to run this Gridlet

Returns:
number of PEs
Pre Condition:
$none
Post Condition:
$none

getGridletHistory

public String getGridletHistory()
Gets the history of this Gridlet. The layout of this history is in a readable table column with time and description as headers.

Returns:
a String containing the history of this Gridlet object.
Pre Condition:
$none
Post Condition:
$result != null

getGridletFinishedSoFar

public double getGridletFinishedSoFar()
Gets the length of this Gridlet that has been executed so far from the latest GridResource. This method is useful when trying to move this Gridlet into different GridResources or to cancel it.

Returns:
the length of a partially executed Gridlet or the full Gridlet length if it is completed
Pre Condition:
$none
Post Condition:
$result >= 0.0

isFinished

public boolean isFinished()
Checks whether this Gridlet has finished execution or not

Returns:
true if this Gridlet has finished execution, false otherwise
Pre Condition:
$none
Post Condition:
$none

setGridletFinishedSoFar

public void setGridletFinishedSoFar(double length)
Sets the length of this Gridlet that has been executed so far. This method is used by ResGridlet class when an application is decided to cancel or to move this Gridlet into different GridResources.

Parameters:
length - length of this Gridlet
See Also:
AllocPolicy, ResGridlet
Pre Condition:
length >= 0.0
Post Condition:
$none

getGridletID

public int getGridletID()
Gets the Gridlet ID

Returns:
the Gridlet ID
Pre Condition:
$none
Post Condition:
$result >= 0

setUserID

public void setUserID(int id)
Sets the user or owner ID of this Gridlet. It is VERY important to set the user ID, otherwise this Gridlet will not be executed in a GridResource.

Parameters:
id - the user ID
Pre Condition:
id >= 0
Post Condition:
$none

getUserID

public int getUserID()
Gets the user or owner ID of this Gridlet

Returns:
the user ID or -1 if the user ID has not been set before
Pre Condition:
$none
Post Condition:
$result >= -1

getResourceID

public int getResourceID()
Gets the latest resource ID that processes this Gridlet

Returns:
the resource ID or -1 if none
Pre Condition:
$none
Post Condition:
$result >= -1

getGridletFileSize

public long getGridletFileSize()
Gets the input file size of this Gridlet BEFORE submitting to a GridResource

Returns:
the input file size of this Gridlet
Pre Condition:
$none
Post Condition:
$result >= 1

getGridletOutputSize

public long getGridletOutputSize()
Gets the output size of this Gridlet AFTER submitting and executing to a GridResource

Returns:
the Gridlet output file size
Pre Condition:
$none
Post Condition:
$result >= 1

setResourceParameter

public void setResourceParameter(int resourceID,
                                 double cost)
Sets the resource parameters for which this Gridlet is going to be executed.
NOTE: This method should be called only by a resource entity, not the user or owner of this Gridlet.

Parameters:
resourceID - the GridResource ID
cost - the cost running this GridResource per second
Pre Condition:
resourceID >= 0, cost > 0.0
Post Condition:
$none

setSubmissionTime

public void setSubmissionTime(double clockTime)
Sets the submission or arrival time of this Gridlet into a GridResource

Parameters:
clockTime - the submission time
Pre Condition:
clockTime >= 0.0
Post Condition:
$none

getSubmissionTime

public double getSubmissionTime()
Gets the submission or arrival time of this Gridlet from the latest GridResource

Returns:
the submission time or 0.0 if none
Pre Condition:
$none
Post Condition:
$result >= 0.0

setExecStartTime

public void setExecStartTime(double clockTime)
Sets the execution start time of this Gridlet inside a GridResource. NOTE: With new functionalities, such as being able to cancel / to pause / to resume this Gridlet, the execution start time only holds the latest one. Meaning, all previous execution start time are ignored.

Parameters:
clockTime - the latest execution start time
Pre Condition:
clockTime >= 0.0
Post Condition:
$none

getExecStartTime

public double getExecStartTime()
Gets the latest execution start time

Returns:
the latest execution start time
Pre Condition:
$none
Post Condition:
$result >= 0.0

setExecParam

public void setExecParam(double wallTime,
                         double actualTime)
Sets this Gridlet's execution parameters. These parameters are set by the GridResource before departure or sending back to the original Gridlet's owner.

Parameters:
wallTime - the time of this Gridlet resides in a GridResource (from arrival time until departure time).
actualTime - the total execution time of this Gridlet in a GridResource.
Pre Condition:
wallTime >= 0.0, actualTime >= 0.0
Post Condition:
$none

setGridletStatus

public void setGridletStatus(int newStatus)
                      throws Exception
Sets the status code of this Gridlet

Parameters:
newStatus - the status code of this Gridlet
Throws:
Exception - Invalid range of Gridlet status
Pre Condition:
newStatus >= 0 && newStatus <= 8
Post Condition:
$none

getGridletStatus

public int getGridletStatus()
Gets the status code of this Gridlet

Returns:
the status code of this Gridlet
Pre Condition:
$none
Post Condition:
$result >= 0

getGridletStatusString

public String getGridletStatusString()
Gets the string representation of the current Gridlet status code

Returns:
the Gridlet status code as a string or null if the status code is unknown
Pre Condition:
$none
Post Condition:
$none

getStatusString

public static String getStatusString(int status)
Gets the string representation of the given Gridlet status code

Parameters:
status - the Gridlet status code
Returns:
the Gridlet status code as a string or null if the status code is unknown
Pre Condition:
$none
Post Condition:
$none

getGridletLength

public double getGridletLength()
Gets the length of this Gridlet

Returns:
the length of this Gridlet
Pre Condition:
$none
Post Condition:
$result >= 0.0

getActualCPUTime

public double getActualCPUTime()
Gets the total execution time of this Gridlet from the latest GridResource

Returns:
the total execution time of this Gridlet in a GridResource
Pre Condition:
$none
Post Condition:
$result >= 0.0

getCostPerSec

public double getCostPerSec()
Gets the cost running this Gridlet in the latest GridResource

Returns:
the cost associated with running this Gridlet or 0.0 if none
Pre Condition:
$none
Post Condition:
$result >= 0.0

getProcessingCost

public double getProcessingCost()
Gets the total cost of processing or executing this Gridlet Processing Cost = actual CPU Time * cost per sec

Returns:
the total cost of processing Gridlet
See Also:
getActualCPUTime(), getCostPerSec()
Pre Condition:
$none
Post Condition:
$result >= 0.0

getWallClockTime

public double getWallClockTime()
Gets the time of this Gridlet resides in the latest GridResource (from arrival time until departure time).

Returns:
the time of this Gridlet resides in a GridResource
Pre Condition:
$none
Post Condition:
$result >= 0.0

getAllResourceName

public String[] getAllResourceName()
Gets all the GridResource names that executed this Gridlet

Returns:
an array of GridResource names or null if it has none
Pre Condition:
$none
Post Condition:
$none

getAllResourceID

public int[] getAllResourceID()
Gets all the GridResource IDs that executed this Gridlet

Returns:
an array of GridResource IDs or null if it has none
Pre Condition:
$none
Post Condition:
$none

getActualCPUTime

public double getActualCPUTime(int resId)
Gets the total execution time of this Gridlet in a given GridResource ID

Parameters:
resId - a GridResource entity ID
Returns:
the total execution time of this Gridlet in a GridResource or 0.0 if not found
Pre Condition:
resId >= 0
Post Condition:
$result >= 0.0

getCostPerSec

public double getCostPerSec(int resId)
Gets the cost running this Gridlet in a given GridResource ID

Parameters:
resId - a GridResource entity ID
Returns:
the cost associated with running this Gridlet or 0.0 if not found
Pre Condition:
resId >= 0
Post Condition:
$result >= 0.0

getGridletFinishedSoFar

public double getGridletFinishedSoFar(int resId)
Gets the length of this Gridlet that has been executed so far in a given GridResource ID. This method is useful when trying to move this Gridlet into different GridResources or to cancel it.

Parameters:
resId - a GridResource entity ID
Returns:
the length of a partially executed Gridlet or the full Gridlet length if it is completed or 0.0 if not found
Pre Condition:
resId >= 0
Post Condition:
$result >= 0.0

getSubmissionTime

public double getSubmissionTime(int resId)
Gets the submission or arrival time of this Gridlet in the given GridResource ID

Parameters:
resId - a GridResource entity ID
Returns:
the submission time or 0.0 if not found
Pre Condition:
resId >= 0
Post Condition:
$result >= 0.0

getWallClockTime

public double getWallClockTime(int resId)
Gets the time of this Gridlet resides in a given GridResource ID (from arrival time until departure time).

Parameters:
resId - a GridResource entity ID
Returns:
the time of this Gridlet resides in the GridResource or 0.0 if not found
Pre Condition:
resId >= 0
Post Condition:
$result >= 0.0

getResourceName

public String getResourceName(int resId)
Gets the GridResource name based on its ID

Parameters:
resId - a GridResource entity ID
Returns:
the GridResource name or null if not found
Pre Condition:
resId >= 0
Post Condition:
$none

getFinishTime

public double getFinishTime()
Gets the finish time of this Gridlet in a GridResource

Returns:
the finish or completion time of this Gridlet or -1 if not finished yet.
Pre Condition:
$none
Post Condition:
$result >= -1

write

protected void write(String str)
Writes this particular history transaction of this Gridlet into a log

Parameters:
str - a history transaction of this Gridlet
Pre Condition:
str != null
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009