GridSim 5.0 beta

gridsim
Class GridSim

Object
  extended by Thread
      extended by Sim_entity
          extended by GridSimCore
              extended by GridSim
All Implemented Interfaces:
Cloneable, Runnable
Direct Known Subclasses:
AdvanceReservation, Auction, Auctioneer, AuctionObserver, GridUser, ReservationRequester, Workload, Workload

public class GridSim
extends GridSimCore

This class is mainly responsible in initialization, running and stopping of the overall simulation.

GridSim must be initialized to set-up the simulation environment before creating any other GridSim entities at the user level. This method also prepares the system for simulation by creating three GridSim internal entities - GridInformationService, GridSimShutdown, GridStatistics. Invoking the startGridSimulation() method starts the Grid simulation. All the resource and user entities must be instantiated in between invoking the above two methods.

Since GridSim version 3.0, all of the I/O methods have been moved into GridSimCore. As a result, this class only concentrates on recording statistics and managing Gridlets. In addition, there are three different ways to initialize GridSim simulation. These methods are:

Since:
GridSim Toolkit 1.0
Author:
Manzur Murshed and Rajkumar Buyya, Anthony Sulistio (re-design this class)
See Also:
Sim_entity, GridSimCore, GridInformationService, GridSimShutdown, GridStatistics
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String GRIDSIM_VERSION_STRING
          Contains the release number of GridSim
static int PAUSE
          Pause for a certain time delay (in seconds) before a resource registers to a Regional GIS entity.
 
Fields inherited from class GridSimCore
input, NETWORK_TYPE, output
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GridSim(String name)
          Allocates a new GridSim object without NETWORK communication channels: "input" and "output" Sim_port.
GridSim(String name, double baudRate)
          Allocates a new GridSim object with NETWORK communication channels: "input" and "output" Sim_port.
GridSim(String name, Link link)
          Allocates a new GridSim object with NETWORK communication channels: "input" and "output" Sim_port.
 
Method Summary
static double clock()
          Gets the current simulation time (based on SimJava simulation clock)
static void disableDebugMode()
          Disables the debug mode (used by the GUI)
static void enableDebugMode()
          Enables the debug mode (used by the GUI)
static LinkedList getAdvancedReservationList()
          Sends a request to Grid Information Service (GIS) entity to get the list of Grid resources only that support Advanced Reservation
static int getEntityId(String entityName)
          Gets the entity ID given its name
 String getEntityName()
          Gets the name of this entity
static String getEntityName(int entityID)
          Gets name of the entity given its entity ID
static String getEntityName(Integer entityID)
          Gets name of the entity given its entity ID
static int getGISId()
          Gets the entity ID of GridInformationService
static int getGridInfoServiceEntityId()
          Gets the entity ID of GridInformationService
static LinkedList getGridResourceList()
          Sends a request to Grid Information Service (GIS) entity to get the list of all Grid resources
static int getGridSimShutdownEntityId()
          Gets the entity id of GridSimShutdown
static int getGridStatisticsEntityId()
          Gets the entity ID of GridStatistics
static int getNetworkType()
          Returns the network type used in this simulation.
 int getNumFreePE(int resourceID)
          Gets the total number of free PEs (Processing Elements) from a resource.
 int getNumFreePE(Integer resourceID)
          Gets the total number of free PEs (Processing Elements) from a resource.
 int getNumPE(int resourceID)
          Gets the total number of PEs (Processing Elements) from a resource
 int getNumPE(Integer resourceID)
          Gets the number of PEs (Processing Elements) from a resource
 ResourceCharacteristics getResourceCharacteristics(int resourceID)
          Gets a ResourceCharacteristics object for a given GridResource ID.
 Accumulator getResourceDynamicInfo(int resourceID)
          Gets the GridResource dynamic fnformation
static Calendar getSimulationCalendar()
          Gets a new copy of initial simulation Calendar.
static Date getSimulationStartDate()
          Deprecated. as of GridSim 5.0, this method has been deprecated. Use getSimulationCalendar() instead.
static Visualizer getVisualizer()
          Returns a reference to the visualiser to be used.
protected  Gridlet gridletCancel(Gridlet gl, int resourceId, double delay)
          Cancels a Gridlet that is currently executing in a given GridResource ID with a delay.
protected  Gridlet gridletCancel(int gridletId, int userId, int resourceId, double delay)
          Cancels a Gridlet that is currently executing in a given GridResource ID with a delay.
protected  boolean gridletMove(Gridlet gl, int srcId, int destId, double delay)
          Moves a Gridlet to the destination GridResource ID
protected  boolean gridletMove(int gridletId, int userId, int srcId, int destId, double delay, boolean ack)
          Moves a Gridlet to the destination GridResource ID
protected  boolean gridletPause(Gridlet gl, int resId, double delay)
          Pauses a Gridlet that is currently executing in a given GridResource ID with a delay.
protected  boolean gridletPause(int gridletId, int userId, int resourceId, double delay, boolean ack)
          Pauses a Gridlet that is currently executing in a given GridResource ID with a delay.
protected  Gridlet gridletReceive()
          Gets a Gridlet belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer).
protected  Gridlet gridletReceive(int gridletId, int resId)
          Gets a Gridlet belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer).
protected  Gridlet gridletReceive(int gridletId, int userId, int resId)
          Gets a Gridlet belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer).
protected  boolean gridletResume(Gridlet gl, int resId, double delay)
          Resumes a Gridlet that is currently pausing in a given GridResource ID with a delay.
NOTE: Resuming a Gridlet only works if it is currently on paused.
protected  boolean gridletResume(int gridletId, int userId, int resourceId, double delay, boolean ack)
          Resumes a Gridlet that is currently pausing in a given GridResource ID with a delay.
protected  int gridletStatus(Gridlet gl, int resourceId)
          Gets the current status of this Gridlet in a given GridResource ID
protected  int gridletStatus(int gridletId, int userId, int resourceId)
          Gets the current status of this Gridlet in a given GridResource ID
protected  boolean gridletSubmit(Gridlet gl, int resID)
          Sends a Gridlet to the destination GridResource ID without any delay.
protected  boolean gridletSubmit(Gridlet gl, int resourceID, double delay, boolean ack)
          Sends a Gridlet to the destination GridResource ID with a specified delay.
protected  boolean gridletSubmit(Gridlet gl, int resourceID, double delay, boolean ack, int netServiceLevel)
          Sends a Gridlet to the destination GridResource ID with a specified delay.
 void gridSimHold(double duration)
          Causes the entity to hold for duration units of simulation time
static void init(int numUser, Calendar cal, boolean traceFlag)
          Initializes GridSim parameters without any statistical entities.
static void init(int numUser, Calendar cal, boolean traceFlag, boolean gis)
          Initializes GridSim parameters without any statistical entities.
static void init(int numUser, Calendar cal, boolean traceFlag, String[] excludeFromFile, String[] excludeFromProcessing, String reportWriterName)
          Initializes GridSim parameters.
static boolean initNetworkType(int networkType)
          Initializes the GridSimCore.NETWORK_TYPE to be used in the simulation.
static boolean isDebugModeEnabled()
          Returns true if the debug mode is enabled
static boolean isResourceExist(int id)
          Checks whether the given GridResource ID exists or not
static boolean isResourceExist(Integer id)
          Checks whether the given GridResource ID exists or not
static boolean isTraceEnabled()
          Checks whether simulation's statistics of other log should be created
static boolean pauseSimulation()
          Pauses the simulation.
static boolean pauseSimulation(long time)
          Pauses the simulation at a given simulation time.
protected  Object receiveEventObject()
          Gets an object belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer).
protected  Object receiveEventObject(Sim_port sourcePort)
          Gets an object belong to the first event CURRENTLY waiting in the given port.
 void recordStatistics(String category, boolean data)
          Records statistics during the event
 void recordStatistics(String category, double data)
          Records statistics during the event
 void recordStatistics(String category, int data)
          Records statistics during the event
 void recordStatistics(String category, String data)
          Records statistics during the event
static boolean resourceSupportAR(int resourceID)
          Checks whether a particular resource supports Advanced Reservation functionalities or not.
static boolean resourceSupportAR(Integer resourceID)
          Checks whether a particular resource supports Advanced Reservation functionalities or not.
static boolean resumeSimulation()
          Resumes the simulation.
static boolean setGIS(GridInformationService gis)
          Sets a GridInformationService (GIS) entity.
protected  void shutdownGridStatisticsEntity()
          Tells the GridStatistics entity the end of the simulation
protected  void shutdownUserEntity()
          Tells all user entities to shut down the simulation.
static void startGridSimulation()
          Starts the execution of GridSim simulation.
static void startGridSimulation(boolean debug)
          This method should be invoked when the user wants to debug a simulation and would like to use GridSim visualiser to view the status of the resource queues and the actions performed by the resource allocation policies.
static void stopGridSimulation()
          Stops Grid Simulation (based on SimJava Sim_system.run_stop()).
 
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, body, 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
 

Field Detail

PAUSE

public static int PAUSE
Pause for a certain time delay (in seconds) before a resource registers to a Regional GIS entity. By default, a resource will pause for 10 seconds before registering. As a rule of thumb, if a network topology is huge (involving several routers), then a resource needs to pause much longer.


GRIDSIM_VERSION_STRING

public static final String GRIDSIM_VERSION_STRING
Contains the release number of GridSim

See Also:
Constant Field Values
Constructor Detail

GridSim

public GridSim(String name)
        throws Exception
Allocates a new GridSim object without NETWORK communication channels: "input" and "output" Sim_port. In summary, this object has NO network communication or bandwidth speed.

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
See Also:
init(int, Calendar, boolean, String[], String[], String), init(int, Calendar, boolean), Sim_entity
Pre Condition:
name != null
Post Condition:
$none

GridSim

public GridSim(String name,
               double baudRate)
        throws Exception
Allocates a new GridSim object with NETWORK communication channels: "input" and "output" Sim_port. In addition, this method will create Input and Output object.

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
baudRate - network communication or bandwidth speed
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
See Also:
init(int, Calendar, boolean, String[], String[], String), init(int, Calendar, boolean), Sim_entity, Input, Output
Pre Condition:
name != null, baudRate > 0.0
Post Condition:
$none

GridSim

public GridSim(String name,
               Link link)
        throws Exception
Allocates a new GridSim object with NETWORK communication channels: "input" and "output" Sim_port. In addition, this method will create Input and Output object.

Use this constructor in a wired network.

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
link - the physical link that connects this entity
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
See Also:
init(int, Calendar, boolean, String[], String[], String), init(int, Calendar, boolean), Sim_entity, Input, Output
Pre Condition:
name != null, link != null
Post Condition:
$none
Method Detail

getSimulationStartDate

public static Date getSimulationStartDate()
Deprecated. as of GridSim 5.0, this method has been deprecated. Use getSimulationCalendar() instead.

Gets a new copy of simulation start date. If the return object is null, then need to initialize it by calling init(int, Calendar, boolean, String[], String[], String) or init(int, Calendar, boolean)

Returns:
a new copy of Date object or null if GridSim hasn't been initialized
See Also:
Date
Pre Condition:
$none
Post Condition:
$none

getSimulationCalendar

public static Calendar getSimulationCalendar()
Gets a new copy of initial simulation Calendar.

Returns:
a new copy of Calendar object or null if GridSim hasn't been initialized
See Also:
init(int, Calendar, boolean, String[], String[], String), init(int, Calendar, boolean)
Pre Condition:
$none
Post Condition:
$none

init

public static void init(int numUser,
                        Calendar cal,
                        boolean traceFlag,
                        String[] excludeFromFile,
                        String[] excludeFromProcessing,
                        String reportWriterName)
Initializes GridSim parameters. This method should be called before creating any entities.

Inside this method, it will create the following GridSim entities:

The Calendar object can be specified using Calendar.getInstance() to denote the start of the simulation time. This simulation time is very important in handling advanced reservations functionalities.

Since GridSim version 5.0, the simulation does not initialise a GridSimRandom object.

Parameters:
numUser - the number of User Entities created. This parameters indicates that GridSimShutdown first waits for User Entities's END_OF_SIMULATION signal before issuing terminate signal to other entities
cal - starting time for this simulation. If it is null, then the time will be taken from Calendar.getInstance().
traceFlag - true if GridSim trace need to be written
excludeFromFile - an array of String containing list of files to be excluded from statistics
excludeFromProcessing - an array of String containing list of processings to be excluded from writing into a file
reportWriterName - a ReportWriter entity name. This entity can be found inside a gridbroker package.
See Also:
GridSimShutdown, GridStatistics, GridInformationService, GridSimRandom
Pre Condition:
numUser >= 0
Post Condition:
$none

init

public static void init(int numUser,
                        Calendar cal,
                        boolean traceFlag)
Initializes GridSim parameters without any statistical entities. Therefore, if a simulation requires to record any statistical data, then need to use init(int, Calendar, boolean, String[], String[], String) instead. This method should be called before creating any entities.

Inside this method, it will create the following GridSim entities:

The Calendar object can be specified using Calendar.getInstance() to denote the start of the simulation time. This simulation time is very important in handling advanced reservations functionalities.

Since GridSim version 5.0, the simulation does not initialise a GridSimRandom object.

Parameters:
numUser - the number of User Entities created. This parameters indicates that GridSimShutdown first waits for User Entities's END_OF_SIMULATION signal before issuing terminate signal to other entities
cal - starting time for this simulation. If it is null, then the time will be taken from Calendar.getInstance()
traceFlag - true if GridSim trace need to be written
See Also:
GridSimShutdown, GridInformationService, GridSimRandom, init(int,Calendar,boolean,String[],String[],String)
Pre Condition:
numUser >= 0
Post Condition:
$none

init

public static void init(int numUser,
                        Calendar cal,
                        boolean traceFlag,
                        boolean gis)
Initializes GridSim parameters without any statistical entities. Therefore, if a simulation requires to record any statistical data, then need to use init(int, Calendar, boolean, String[], String[], String) instead. This method should be called before creating any entities.

Inside this method, it will create the following GridSim entities:

The Calendar object can be specified using Calendar.getInstance() to denote the start of the simulation time. This simulation time is very important in handling advanced reservations functionalities.

Since GridSim version 5.0, the simulation does not initialise a GridSimRandom object.

Parameters:
numUser - the number of User Entities created. This parameters indicates that GridSimShutdown first waits for all user entities's END_OF_SIMULATION signal before issuing terminate signal to other entities
cal - starting time for this simulation. If it is null, then the time will be taken from Calendar.getInstance()
traceFlag - true if GridSim trace need to be written
gis - true if you want to use a DEFAULT GridInformationService entity.
See Also:
GridSimShutdown, GridInformationService, GridSimRandom, setGIS(GridInformationService), init(int,Calendar,boolean,String[],String[],String)
Pre Condition:
numUser >= 0
Post Condition:
$none

setGIS

public static boolean setGIS(GridInformationService gis)
Sets a GridInformationService (GIS) entity. This method is useful when you want a different type of GIS entity. This method must be called before startGridSimulation() method.

Parameters:
gis - a GIS object
Returns:
true if successful, false otherwise
See Also:
startGridSimulation()
Pre Condition:
gis != null
Post Condition:
$none

startGridSimulation

public static void startGridSimulation()
                                throws NullPointerException
Starts the execution of GridSim simulation. It waits for complete execution of all entities, i.e. until all entities threads reach non-RUNNABLE state by exiting from the body() method. Then, it kills threads of all entities.

Note: This method should be called after all the entities have been setup and added, and their ports are linked.

Throws:
NullPointerException - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
See Also:
init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
$none
Post Condition:
$none

enableDebugMode

public static void enableDebugMode()
Enables the debug mode (used by the GUI)


disableDebugMode

public static void disableDebugMode()
Disables the debug mode (used by the GUI)


isDebugModeEnabled

public static boolean isDebugModeEnabled()
Returns true if the debug mode is enabled

Returns:
true if the debug mode is enabled; false otherwise

startGridSimulation

public static void startGridSimulation(boolean debug)
                                throws NullPointerException
This method should be invoked when the user wants to debug a simulation and would like to use GridSim visualiser to view the status of the resource queues and the actions performed by the resource allocation policies. Note that if the visualiser is used, this method does not start the simulation in fact, it starts the visualisation tool. The visualisation tool in turn, can start the simulation. Note: This method should be called after all the entities have been setup and added, and their ports are linked.

Parameters:
debug - true if the visualizer is used or false otherwise.
Throws:
NullPointerException - This happens when creating this entity before initialising GridSim package or this entity name is null or empty
See Also:
init(int, Calendar, boolean)

getVisualizer

public static Visualizer getVisualizer()
Returns a reference to the visualiser to be used.

Returns:
a reference to the visualiser to be used.

pauseSimulation

public static boolean pauseSimulation()
Pauses the simulation. This method should be used for debugging purposes only

Returns:
true if the simulation has been paused or false otherwise.

pauseSimulation

public static boolean pauseSimulation(long time)
Pauses the simulation at a given simulation time. This method should be used for debugging purposes only

Parameters:
time - the time when the simulation should be paused
Returns:
true if the simulation can be paused or false otherwise.

resumeSimulation

public static boolean resumeSimulation()
Resumes the simulation. This method should be used for debugging purposes only

Returns:
true if the simulation has been resumed or false otherwise.

clock

public static double clock()
Gets the current simulation time (based on SimJava simulation clock)

Returns:
The current simulation time from the simulation clock
See Also:
Sim_system.clock()
Pre Condition:
$none
Post Condition:
$result >= 0.0

gridSimHold

public void gridSimHold(double duration)
Causes the entity to hold for duration units of simulation time

Parameters:
duration - the amount of time to hold
Pre Condition:
$none
Post Condition:
$none

stopGridSimulation

public static void stopGridSimulation()
                               throws NullPointerException
Stops Grid Simulation (based on SimJava Sim_system.run_stop()). This should be ony called if any of the user defined entities explicitly want to terminate simulation during execution.

Throws:
NullPointerException - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
See Also:
init(int, Calendar, boolean, String[], String[], String), Sim_system.run_stop()
Pre Condition:
$none
Post Condition:
$none

receiveEventObject

protected Object receiveEventObject()
Gets an object belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer). If there are no events, then wait indefinitely for an event to arrive.

Returns:
An event's object
Pre Condition:
$none
Post Condition:
$none

receiveEventObject

protected Object receiveEventObject(Sim_port sourcePort)
Gets an object belong to the first event CURRENTLY waiting in the given port. If there are no events, then wait indefinitely for an event to arrive.

Parameters:
sourcePort - a Sim_port object which is used to connect entities for event passing
Returns:
An event's data or null if the source port is empty.
See Also:
Sim_port
Pre Condition:
sourcePort != null
Post Condition:
$none

gridletSubmit

protected boolean gridletSubmit(Gridlet gl,
                                int resID)
Sends a Gridlet to the destination GridResource ID without any delay. An acknowledgement to denote the successful of this method is by default off or false.

Parameters:
gl - a Gridlet object to be sent
resID - an unique resource ID
Returns:
true if this Gridlet has been submitted to the destination GridResource, false otherwise. Submitting a Gridlet can be failed for the one or more following reasons:
  • if the acknowledgment status in the parameter of this method is set to false
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if a Gridlet object is null or empty;
  • if a Gridlet object has finished executing beforehand
Pre Condition:
gl != null, resID >= 0
Post Condition:
$none

gridletSubmit

protected boolean gridletSubmit(Gridlet gl,
                                int resourceID,
                                double delay,
                                boolean ack)
Sends a Gridlet to the destination GridResource ID with a specified delay.

Parameters:
gl - a Gridlet object to be sent
resourceID - an unique resource ID
delay - delay time or 0.0 if want to execute NOW
ack - an acknowledgment status. true if want to know the result of this method, false otherwise or don't care.
Returns:
true if this Gridlet has been submitted to the destination GridResource, false otherwise. Submitting a Gridlet can be failed for the one or more following reasons:
  • if the acknowledgment status in the parameter of this method is set to false
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet object is null or empty;
  • if a Gridlet object has finished executing beforehand
See Also:
Gridlet.isFinished(), gridletReceive()
Pre Condition:
gl != null, resourceID >= 0, delay >= 0.0
Post Condition:
$none

gridletSubmit

protected boolean gridletSubmit(Gridlet gl,
                                int resourceID,
                                double delay,
                                boolean ack,
                                int netServiceLevel)
Sends a Gridlet to the destination GridResource ID with a specified delay.

Parameters:
gl - a Gridlet object to be sent
resourceID - an unique resource ID
delay - delay time or 0.0 if want to execute NOW
ack - an acknowledgment status. true if want to know the result of this method, false otherwise or don't care.
netServiceLevel - this can be set so that network entities can provide differentiated services if they are supported.
Returns:
true if this Gridlet has been submitted to the destination GridResource, false otherwise. Submitting a Gridlet can be failed for the one or more following reasons:
  • if the acknowledgment status in the parameter of this method is set to false
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet object is null or empty;
  • if a Gridlet object has finished executing beforehand
See Also:
Gridlet.isFinished(), gridletReceive()
Pre Condition:
gl != null, resourceID >= 0, delay >= 0.0
Post Condition:
$none

gridletReceive

protected Gridlet gridletReceive()
Gets a Gridlet belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer). If there are no events, then wait indefinitely for an event to arrive.

Returns:
A Gridlet object or null if an error occurs.
Pre Condition:
$none
Post Condition:
$none

gridletReceive

protected Gridlet gridletReceive(int gridletId,
                                 int userId,
                                 int resId)
Gets a Gridlet belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer). If there are no events, then wait indefinitely for an event to arrive.

Parameters:
gridletId - a Gridlet ID
userId - a user ID
resId - a grid resource ID
Returns:
A Gridlet object or null if an error occurs.
Pre Condition:
gridletId >= 0, userId > 0, resId > 0
Post Condition:
$none

gridletReceive

protected Gridlet gridletReceive(int gridletId,
                                 int resId)
Gets a Gridlet belong to the first event CURRENTLY waiting in this entity's deferred queue (incoming buffer). If there are no events, then wait indefinitely for an event to arrive.

Parameters:
gridletId - a Gridlet ID
resId - a grid resource ID
Returns:
A Gridlet object or null if an error occurs.
Pre Condition:
gridletId >= 0, resId > 0
Post Condition:
$none

gridletCancel

protected Gridlet gridletCancel(Gridlet gl,
                                int resourceId,
                                double delay)
Cancels a Gridlet that is currently executing in a given GridResource ID with a delay.
NOTE: Canceling a Gridlet operation can take a long time over a slow network if the Gridlet size is big.

Parameters:
gl - a Gridlet object to be canceled
resourceId - an unique resource ID
delay - delay time or 0.0 if want to cancel NOW
Returns:
the canceled Gridlet or nullfinished in time of cancellation, then this method will return the finished Gridlet. Canceling a Gridlet can be failed for the one or more following reasons:
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet object is null or empty;
Pre Condition:
gl != null, resourceId >= 0, delay >= 0.0
Post Condition:
$none

gridletCancel

protected Gridlet gridletCancel(int gridletId,
                                int userId,
                                int resourceId,
                                double delay)
Cancels a Gridlet that is currently executing in a given GridResource ID with a delay.
NOTE: Canceling a Gridlet operation can be slow over a slow network if the Gridlet size is big.

Parameters:
gridletId - a Gridlet ID
userId - the user or owner ID of this Gridlet
resourceId - an unique resource ID to which this Gridlet was previously sent to
delay - delay time or 0.0 if want to cancel NOW
Returns:
the canceled Gridlet or nullfinished in time of cancellation, then this method will return the finished Gridlet. Canceling a Gridlet can be failed for the one or more following reasons:
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
Pre Condition:
gridletId >= 0, userId >= 0, resourceId >= 0, delay >= 0.0
Post Condition:
$none

gridletPause

protected boolean gridletPause(Gridlet gl,
                               int resId,
                               double delay)
Pauses a Gridlet that is currently executing in a given GridResource ID with a delay.

Parameters:
gl - a Gridlet object to be sent
resId - an unique resource ID
delay - delay time or 0.0 if want to execute NOW
Returns:
true if this Gridlet has been paused successfully in the destination GridResource, false otherwise. Pausing a Gridlet can be failed for the one or more following reasons:
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet object is null or empty;
  • if a Gridlet object has finished executing beforehand. The Gridlet needs to be retrieved by using gridletReceive()
Pre Condition:
gl != null, resId >= 0, delay >= 0.0
Post Condition:
$none

gridletPause

protected boolean gridletPause(int gridletId,
                               int userId,
                               int resourceId,
                               double delay,
                               boolean ack)
Pauses a Gridlet that is currently executing in a given GridResource ID with a delay.

Parameters:
gridletId - a Gridlet ID
userId - the user or owner ID of this Gridlet
resourceId - an unique resource ID
delay - delay time or 0.0 if want to execute NOW
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
Returns:
true if this Gridlet has been paused successfully in the destination GridResource, false otherwise. Pausing a Gridlet can be failed for the one or more following reasons:
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet object has finished executing beforehand. The Gridlet needs to be retrieved by using gridletReceive()
Pre Condition:
gridletId >= 0, userId >= 0, resourceId >= 0, delay >= 0.0
Post Condition:
$none

gridletStatus

protected int gridletStatus(Gridlet gl,
                            int resourceId)
Gets the current status of this Gridlet in a given GridResource ID

Parameters:
gl - a Gridlet object
resourceId - a GridResource ID that executes this Gridlet object
Returns:
the current Gridlet status or -1 if not found. The various Gridlet status can be found in Gridlet class.
See Also:
Gridlet
Pre Condition:
gl != null, resourceId > 0
Post Condition:
$none

gridletStatus

protected int gridletStatus(int gridletId,
                            int userId,
                            int resourceId)
Gets the current status of this Gridlet in a given GridResource ID

Parameters:
gridletId - a Gridlet ID
userId - the user or owner of this Gridlet object
resourceId - a GridResource ID that executes this Gridlet object
Returns:
the current Gridlet status or -1 if not found. The various Gridlet status can be found in Gridlet class.
See Also:
Gridlet
Pre Condition:
gridletId > 0, userId > 0, resourceId > 0
Post Condition:
$none

gridletResume

protected boolean gridletResume(Gridlet gl,
                                int resId,
                                double delay)
Resumes a Gridlet that is currently pausing in a given GridResource ID with a delay.
NOTE: Resuming a Gridlet only works if it is currently on paused.

Parameters:
gl - a Gridlet object to be sent
resId - an unique resource ID
delay - delay time or 0.0 if want to execute NOW
Returns:
true if this Gridlet has been resumed successfully in the destination GridResource, false otherwise. Resuming a Gridlet can be failed for the one or more following reasons:
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet object is null or empty
  • if a Gridlet is not currently on paused
Pre Condition:
gl != null, resId >= 0, delay >= 0.0
Post Condition:
$none

gridletResume

protected boolean gridletResume(int gridletId,
                                int userId,
                                int resourceId,
                                double delay,
                                boolean ack)
Resumes a Gridlet that is currently pausing in a given GridResource ID with a delay.
NOTE: Resuming a Gridlet only works if it is currently on paused.

Parameters:
gridletId - a Gridlet ID
userId - the user or owner ID of this Gridlet
resourceId - an unique resource ID
delay - delay time or 0.0 if want to execute NOW
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
Returns:
true if this Gridlet has been resumed successfully in the destination GridResource, false otherwise. Resuming a Gridlet can be failed for the one or more following reasons:
  • if a GridResource ID doesn't exist
  • if a Gridlet ID doesn't exist
  • if a Gridlet's user ID doesn't exist
  • if the delay time is negative
  • if a Gridlet is not currently on paused
Pre Condition:
gridletId >= 0, userId >= 0, resourceId >= 0, delay >= 0.0
Post Condition:
$none

gridletMove

protected boolean gridletMove(Gridlet gl,
                              int srcId,
                              int destId,
                              double delay)
Moves a Gridlet to the destination GridResource ID

Parameters:
gl - a Gridlet object
srcId - the GridResource ID that is currently executing this Gridlet
destId - the new GridResource ID
delay - simulation delay
Returns:
true if this Gridlet has moved successfully, false otherwise. Moving a Gridlet can be failed, due to one or more following reasons:
  • if a Gridlet object is null
  • if one or both GridResource ID don't exist
  • if the delay is negative
  • if a Gridlet in the GridResource has completed beforehand. The Gridlet can be retrieved by using gridletReceive()
Pre Condition:
gl != null, srcId > 0, destId > 0, delay >= 0.0
Post Condition:
$result = true || false

gridletMove

protected boolean gridletMove(int gridletId,
                              int userId,
                              int srcId,
                              int destId,
                              double delay,
                              boolean ack)
Moves a Gridlet to the destination GridResource ID

Parameters:
gridletId - a Gridlet ID
userId - the owner or user ID of this Gridlet
srcId - the GridResource ID that is currently executing this Gridlet
destId - the new GridResource ID
delay - simulation delay
ack - an acknowledgement, i.e. true if wanted to know whether this operation is success or not, false otherwise (don't care)
Returns:
true if this Gridlet has moved successfully, false otherwise. Moving a Gridlet can be failed, due to one or more following reasons:
  • if a Gridlet ID doesn't exist
  • if the owner of user ID of this Gridlet doesn't exist
  • if one or both GridResource ID don't exist
  • if the delay is negative
  • if a Gridlet in the GridResource has completed beforehand. The Gridlet can be retrieved by using gridletReceive()
Pre Condition:
gridletId > 0, userId > 0, srcId > 0, destId > 0, delay >= 0.0
Post Condition:
$result = true || false

getEntityName

public String getEntityName()
Gets the name of this entity

Returns:
the Entity name or null if this object does not have one
Pre Condition:
$none
Post Condition:
$none

getEntityName

public static String getEntityName(int entityID)
Gets name of the entity given its entity ID

Parameters:
entityID - the entity ID
Returns:
the Entity name or null if this object does not have one
Pre Condition:
entityID > 0
Post Condition:
$none

getEntityName

public static String getEntityName(Integer entityID)
Gets name of the entity given its entity ID

Parameters:
entityID - the entity ID
Returns:
the Entity name or null if this object does not have one
Pre Condition:
entityID > 0
Post Condition:
$none

getEntityId

public static int getEntityId(String entityName)
Gets the entity ID given its name

Parameters:
entityName - an Entity name
Returns:
the Entity ID or -1 if it is not found
Pre Condition:
entityName != null
Post Condition:
$result >= -1

getGridStatisticsEntityId

public static int getGridStatisticsEntityId()
Gets the entity ID of GridStatistics

Returns:
the Entity ID or -1 if it is not found
Pre Condition:
$none
Post Condition:
$result >= -1

getGridInfoServiceEntityId

public static int getGridInfoServiceEntityId()
Gets the entity ID of GridInformationService

Returns:
the Entity ID or -1 if it is not found
Pre Condition:
$none
Post Condition:
$result >= -1

getGISId

public static int getGISId()
Gets the entity ID of GridInformationService

Returns:
the GIS entity ID or -1 if it is not found
Pre Condition:
$none
Post Condition:
$result >= -1

getGridSimShutdownEntityId

public static int getGridSimShutdownEntityId()
Gets the entity id of GridSimShutdown

Returns:
the Entity ID or -1 if it is not found
Pre Condition:
$none
Post Condition:
$result >= -1

shutdownUserEntity

protected void shutdownUserEntity()
Tells all user entities to shut down the simulation. GridSimShutdown entity waits for all users termination before shuting down other entities.

See Also:
GridSimShutdown
Pre Condition:
$none
Post Condition:
$none

shutdownGridStatisticsEntity

protected void shutdownGridStatisticsEntity()
Tells the GridStatistics entity the end of the simulation

Pre Condition:
$none
Post Condition:
$none

getGridResourceList

public static LinkedList getGridResourceList()
Sends a request to Grid Information Service (GIS) entity to get the list of all Grid resources

Returns:
A LinkedList containing GridResource ID (as an Integer object) or null if a GIS entity hasn't been created before
Pre Condition:
$none
Post Condition:
$none

resourceSupportAR

public static boolean resourceSupportAR(int resourceID)
Checks whether a particular resource supports Advanced Reservation functionalities or not.

Parameters:
resourceID - a resource ID
Returns:
true if a resource supports Advanced Reservation functionalities, false otherwise
Pre Condition:
resourceID > 0
Post Condition:
$none

resourceSupportAR

public static boolean resourceSupportAR(Integer resourceID)
Checks whether a particular resource supports Advanced Reservation functionalities or not.

Parameters:
resourceID - a resource ID
Returns:
true if a resource supports Advanced Reservation functionalities, false otherwise
Pre Condition:
resourceID != null
Post Condition:
$none

getAdvancedReservationList

public static LinkedList getAdvancedReservationList()
Sends a request to Grid Information Service (GIS) entity to get the list of Grid resources only that support Advanced Reservation

Returns:
A LinkedList containing GridResource ID (as an Integer object) or null if a GIS entity hasn't been created before
Pre Condition:
$none
Post Condition:
$none

isResourceExist

public static boolean isResourceExist(int id)
Checks whether the given GridResource ID exists or not

Parameters:
id - a GridResource id
Returns:
true if the given ID exists, false otherwise
Pre Condition:
id >= 0
Post Condition:
$none

isResourceExist

public static boolean isResourceExist(Integer id)
Checks whether the given GridResource ID exists or not

Parameters:
id - a GridResource id
Returns:
true if the given ID exists, false otherwise
Pre Condition:
id != null
Post Condition:
$none

isTraceEnabled

public static boolean isTraceEnabled()
Checks whether simulation's statistics of other log should be created

Returns:
true if the information should be logged or false otherwise.

getNumPE

public int getNumPE(int resourceID)
Gets the total number of PEs (Processing Elements) from a resource

Parameters:
resourceID - a resource ID
Returns:
total number of PE or -1 if invalid resource ID
Pre Condition:
resourceID > 0
Post Condition:
$none

getNumPE

public int getNumPE(Integer resourceID)
Gets the number of PEs (Processing Elements) from a resource

Parameters:
resourceID - a resource ID
Returns:
total number of PEs or -1 if invalid resource ID
Pre Condition:
resourceID != null
Post Condition:
$none

getNumFreePE

public int getNumFreePE(int resourceID)
Gets the total number of free PEs (Processing Elements) from a resource.
NOTE: Due to the dynamic nature of a Grid environment, the number of free PEs only reflect to the current status of a resource at the time of this request received.

Parameters:
resourceID - a resource ID
Returns:
total number of free PE or -1 if invalid resource ID
Pre Condition:
resourceID > 0
Post Condition:
$none

getNumFreePE

public int getNumFreePE(Integer resourceID)
Gets the total number of free PEs (Processing Elements) from a resource.
NOTE: Due to the dynamic nature of a Grid environment, the number of free PEs only reflect to the current status of a resource at the time of this request received.

Parameters:
resourceID - a resource ID
Returns:
total number of free PE or -1 if invalid resource ID
Pre Condition:
resourceID != null
Post Condition:
$none

getResourceCharacteristics

public ResourceCharacteristics getResourceCharacteristics(int resourceID)
Gets a ResourceCharacteristics object for a given GridResource ID.
NOTE: This method returns a reference of ResourceCharacteristics object, NOT a copy of it. As a result, some of ResourceCharacteristics attributes, such as PE availability might change over time. Use getNumFreePE(int) to determine number of free PE at the time of a request instead.

Parameters:
resourceID - the resource ID
Returns:
An object of ResourceCharacteristics or null if a GridResource doesn't exist or an error occurs
See Also:
ResourceCharacteristics
Pre Condition:
resourceID > 0
Post Condition:
$none

getResourceDynamicInfo

public Accumulator getResourceDynamicInfo(int resourceID)
Gets the GridResource dynamic fnformation

Parameters:
resourceID - the resource ID
Returns:
An object of Accumulator containing the GridResource load or null if a GridResource doesn't exist or an error occurs
Pre Condition:
resourceID > 0
Post Condition:
$none

recordStatistics

public void recordStatistics(String category,
                             double data)
Records statistics during the event

Parameters:
category - a category name
data - a value to be recorded
Pre Condition:
category != null, data >= 0.0
Post Condition:
$none

recordStatistics

public void recordStatistics(String category,
                             int data)
Records statistics during the event

Parameters:
category - a category name
data - a value to be recorded
Pre Condition:
category != null, data >= 0.0
Post Condition:
$none

recordStatistics

public void recordStatistics(String category,
                             String data)
Records statistics during the event

Parameters:
category - a category name
data - a value to be recorded
Pre Condition:
category != null, data != null
Post Condition:
$none

recordStatistics

public void recordStatistics(String category,
                             boolean data)
Records statistics during the event

Parameters:
category - a category name
data - a value to be recorded
Pre Condition:
category != null, data == true || false
Post Condition:
$none

initNetworkType

public static boolean initNetworkType(int networkType)
Initializes the GridSimCore.NETWORK_TYPE to be used in the simulation. By default, the GridSimCore.NETWORK_TYPE is set to GridSimTags.NET_PACKET_LEVEL.

Parameters:
networkType - network type
Returns:
true if the network type has been initialized successfully or false otherwise.
See Also:
GridSimCore.NETWORK_TYPE, GridSimTags.NET_PACKET_LEVEL, GridSimTags.NET_FLOW_LEVEL, GridSimTags.NET_BUFFER_PACKET_LEVEL

getNetworkType

public static int getNetworkType()
Returns the network type used in this simulation.

Returns:
the network type
See Also:
GridSimCore.NETWORK_TYPE, GridSimTags.NET_PACKET_LEVEL, GridSimTags.NET_FLOW_LEVEL, GridSimTags.NET_BUFFER_PACKET_LEVEL

GridSim 5.0 beta

The University of Melbourne, Australia, 2009