GridSim 5.0 beta

gridsim.util
Class Workload

Object
  extended by Thread
      extended by Sim_entity
          extended by GridSimCore
              extended by GridSim
                  extended by Workload
All Implemented Interfaces:
Cloneable, Runnable

public class Workload
extends GridSim

The main purpose of this class is to create a realistic simulation environment where your jobs or Gridlets are competing with others. In other words, the grid resource might not be available at certain times. In addition, the arrival time of jobs are also captured in the trace file.

This class is responsible for reading resource traces from a file and sends Gridlets to only one destinated resource.
NOTE:

By default, this class follows the standard workload format as specified in http://www.cs.huji.ac.il/labs/parallel/workload/
However, you can use other format by calling the below methods before running the simulation:

Since:
GridSim Toolkit 3.1
Author:
Anthony Sulistio
See Also:
GridSim.init(int, Calendar, boolean)
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class GridSim
GRIDSIM_VERSION_STRING, PAUSE
 
Fields inherited from class GridSimCore
input, NETWORK_TYPE, output
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Workload(String name, double baudRate, double propDelay, int MTU, String fileName, String resourceName, int rating)
          Create a new Workload object with the network extension.
Workload(String name, Link link, String fileName, String resourceName, int rating)
          Create a new Workload object with the network extension.
Workload(String name, String fileName, String resourceName, int rating)
          Create a new Workload object without using the network extension.
 
Method Summary
 void body()
          Reads from a given file when the simulation starts running.
 ArrayList<Gridlet> getGridletList()
          Gets a list of completed Gridlets
 void printGridletList(boolean history)
          Prints the Gridlet objects
 boolean setComment(String comment)
          Identifies the start of a comment line.
 boolean setField(int maxField, int jobNum, int submitTime, int runTime, int numProc)
          Tells this class what to look in the trace file.
 boolean setGridletFileSize(int size)
          Sets a Gridlet file size (in byte) for sending to/from a resource.
 
Methods inherited from class GridSim
clock, disableDebugMode, enableDebugMode, getAdvancedReservationList, getEntityId, getEntityName, getEntityName, getEntityName, getGISId, getGridInfoServiceEntityId, getGridResourceList, getGridSimShutdownEntityId, getGridStatisticsEntityId, getNetworkType, getNumFreePE, getNumFreePE, getNumPE, getNumPE, getResourceCharacteristics, getResourceDynamicInfo, getSimulationCalendar, getSimulationStartDate, getVisualizer, gridletCancel, gridletCancel, gridletMove, gridletMove, gridletPause, gridletPause, gridletReceive, gridletReceive, gridletReceive, gridletResume, gridletResume, gridletStatus, gridletStatus, gridletSubmit, gridletSubmit, gridletSubmit, gridSimHold, init, init, init, initNetworkType, isDebugModeEnabled, isResourceExist, isResourceExist, isTraceEnabled, pauseSimulation, pauseSimulation, receiveEventObject, receiveEventObject, recordStatistics, recordStatistics, recordStatistics, recordStatistics, resourceSupportAR, resourceSupportAR, resumeSimulation, setGIS, shutdownGridStatisticsEntity, shutdownUserEntity, startGridSimulation, startGridSimulation, stopGridSimulation
 
Methods inherited from class GridSimCore
finalizeGridSimulation, getLink, getPingResult, isNetworked, ping, ping, ping, ping, pingBlockingCall, pingBlockingCall, pingBlockingCall, pingBlockingCall, send, send, send, send, send, send, setBackgroundTraffic, setBackgroundTraffic, terminateIOEntities
 
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

Workload

public Workload(String name,
                String fileName,
                String resourceName,
                int rating)
         throws ParameterException,
                Exception
Create a new Workload object without using the network extension. This means this entity directly sends Gridlets to a destinated resource without going through a wired network.
NOTE: You can not use this constructor in an experiment that uses a wired network topology.

Parameters:
name - this entity name
fileName - the workload trace filename in one of the following format: ASCII text, zip, gz.
resourceName - the resource name
rating - the resource's PE rating
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
ParameterException - This happens for the following conditions:
  • the entity name is null or empty
  • the workload trace file name is null or empty
  • the resource entity name is null or empty
  • the resource PE rating <= 0
Pre Condition:
name != null, fileName != null, resourceName != null, rating > 0
Post Condition:
$none

Workload

public Workload(String name,
                double baudRate,
                double propDelay,
                int MTU,
                String fileName,
                String resourceName,
                int rating)
         throws ParameterException,
                Exception
Create a new Workload object with the network extension. This means this entity directly sends Gridlets to a destinated resource through a link. The link is automatically created by this constructor.

Parameters:
name - this entity name
baudRate - baud rate of this link (bits/s)
propDelay - Propagation delay of the Link in milli seconds
MTU - Maximum Transmission Unit of the Link in bytes. Packets which are larger than the MTU should be split up into MTU size units. For example, a 1024 byte packet trying to cross a 576 byte MTU link should get split into 2 packets of 576 bytes and 448 bytes.
fileName - the workload trace filename in one of the following format: ASCII text, zip, gz.
resourceName - the resource name
rating - the resource's PE rating
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
ParameterException - This happens for the following conditions:
  • the entity name is null or empty
  • baudRate <= 0
  • propDelay <= 0
  • MTU <= 0
  • the workload trace file name is null or empty
  • the resource entity name is null or empty
  • the resource PE rating <= 0
Pre Condition:
name != null, baudRate > 0, propDelay > 0, MTU > 0, fileName != null, resourceName != null, rating > 0
Post Condition:
$none

Workload

public Workload(String name,
                Link link,
                String fileName,
                String resourceName,
                int rating)
         throws ParameterException,
                Exception
Create a new Workload object with the network extension. This means this entity directly sends Gridlets to a destinated resource through a link. The link is automatically created by this constructor.

Parameters:
name - this entity name
link - the link that will be used to connect this Workload to another entity or a Router.
fileName - the workload trace filename in one of the following format: ASCII text, zip, gz.
resourceName - the resource name
rating - the resource's PE rating
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
ParameterException - This happens for the following conditions:
  • the entity name is null or empty
  • the link is empty
  • the workload trace file name is null or empty
  • the resource entity name is null or empty
  • the resource PE rating <= 0
Pre Condition:
name != null, link != null, fileName != null, resourceName != null, rating > 0
Post Condition:
$none
Method Detail

setGridletFileSize

public boolean setGridletFileSize(int size)
Sets a Gridlet file size (in byte) for sending to/from a resource.

Parameters:
size - a Gridlet file size (in byte)
Returns:
true if it is successful, false otherwise
Pre Condition:
size > 0
Post Condition:
$none

setComment

public boolean setComment(String comment)
Identifies the start of a comment line. Hence, a line that starts with a given comment will be ignored.

Parameters:
comment - a character that denotes the start of a comment, e.g. ";" or "#"
Returns:
true if it is successful, false otherwise
Pre Condition:
comment != null
Post Condition:
$none

setField

public boolean setField(int maxField,
                        int jobNum,
                        int submitTime,
                        int runTime,
                        int numProc)
Tells this class what to look in the trace file. This method should be called before the start of the simulation.

By default, this class follows the standard workload format as specified in http://www.cs.huji.ac.il/labs/parallel/workload/
However, you can use other format by calling this method.

The parameters must be a positive integer number starting from 1. A special case is where jobNum == -1, meaning the job or gridlet ID starts at 1.

Parameters:
maxField - max. number of field/column in one row
jobNum - field/column number for locating the job ID
submitTime - field/column number for locating the job submit time
runTime - field/column number for locating the job run time
numProc - field/column number for locating the number of PEs required to run a job
Returns:
true if successful, false otherwise
Pre Condition:
maxField > 0, submitTime > 0, runTime > 0, numProc > 0
Post Condition:
$none

getGridletList

public ArrayList<Gridlet> getGridletList()
Gets a list of completed Gridlets

Returns:
a list of Gridlets
Pre Condition:
$none
Post Condition:
$none

printGridletList

public void printGridletList(boolean history)
Prints the Gridlet objects

Parameters:
history - true means printing each Gridlet's history, false otherwise
Pre Condition:
$none
Post Condition:
$none

body

public void body()
Reads from a given file when the simulation starts running. Then submits Gridlets to a resource and collects them before exiting. To collect the completed Gridlets, use getGridletList()

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

GridSim 5.0 beta

The University of Melbourne, Australia, 2009