|
GridSim 5.0 beta | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object Thread Sim_entity GridSimCore GridSim
public class GridSim
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:
init(int, Calendar, boolean, String[], String[], String)
method. GridStatistics
,
GridSimRandom
, GridSimShutdown
and
GridInformationService
entity. init(int, Calendar, boolean)
method. GridSimRandom
,
GridSimShutdown
and
GridInformationService
entity. init(int, Calendar, boolean, boolean)
method.GridSimRandom
and
GridSimShutdown
. A different type of
GridInformationService
entity needs to be entered
using setGIS(GridInformationService)
method before running
the simulation.
Sim_entity
,
GridSimCore
,
GridInformationService
,
GridSimShutdown
,
GridStatistics
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 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 |
---|
public static int PAUSE
public static final String GRIDSIM_VERSION_STRING
Constructor Detail |
---|
public GridSim(String name) throws Exception
name
- the name to be associated with this entity (as
required by Sim_entity class from simjava package)
Exception
- This happens when creating this entity before
initializing GridSim package or this entity name is
null or emptyinit(int, Calendar, boolean, String[], String[],
String)
,
init(int, Calendar, boolean)
,
Sim_entity
public GridSim(String name, double baudRate) throws Exception
name
- the name to be associated with this entity (as
required by Sim_entity class from simjava package)baudRate
- network communication or bandwidth speed
Exception
- This happens when creating this entity before
initializing GridSim package or this entity name is
null or emptyinit(int, Calendar, boolean, String[], String[],
String)
,
init(int, Calendar, boolean)
,
Sim_entity
,
Input
,
Output
public GridSim(String name, Link link) throws Exception
Use this constructor in a wired network.
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
Exception
- This happens when creating this entity before
initializing GridSim package or this entity name is
null or emptyinit(int, Calendar, boolean, String[], String[],
String)
,
init(int, Calendar, boolean)
,
Sim_entity
,
Input
,
Output
Method Detail |
---|
public static Date getSimulationStartDate()
getSimulationCalendar()
instead.
init(int, Calendar, boolean, String[], String[], String)
or
init(int, Calendar, boolean)
Date
public static Calendar getSimulationCalendar()
init(int, Calendar, boolean, String[], String[],
String)
,
init(int, Calendar, boolean)
public static void init(int numUser, Calendar cal, boolean traceFlag, String[] excludeFromFile, String[] excludeFromProcessing, String reportWriterName)
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.
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 entitiescal
- 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 writtenexcludeFromFile
- an array of String containing list of files to
be excluded from statisticsexcludeFromProcessing
- an array of String containing list of
processings to be excluded from writing
into a filereportWriterName
- a ReportWriter entity name. This entity
can be found inside a gridbroker package.GridSimShutdown
,
GridStatistics
,
GridInformationService
,
GridSimRandom
public static void init(int numUser, Calendar cal, boolean traceFlag)
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.
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 entitiescal
- 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 writtenGridSimShutdown
,
GridInformationService
,
GridSimRandom
,
init(int,Calendar,boolean,String[],String[],String)
public static void init(int numUser, Calendar cal, boolean traceFlag, boolean gis)
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:
setGIS(GridInformationService)
method before running
or starting the simulation.
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.
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 entitiescal
- 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 writtengis
- true if you want to use a DEFAULT
GridInformationService
entity.GridSimShutdown
,
GridInformationService
,
GridSimRandom
,
setGIS(GridInformationService)
,
init(int,Calendar,boolean,String[],String[],String)
public static boolean setGIS(GridInformationService gis)
startGridSimulation()
method.
gis
- a GIS object
startGridSimulation()
public static void startGridSimulation() throws NullPointerException
Note: This method should be called after all the entities have been setup and added, and their ports are linked.
NullPointerException
- This happens when creating this entity
before initializing GridSim package or this entity name is
null or emptyinit(int, Calendar, boolean, String[], String[],
String)
public static void enableDebugMode()
public static void disableDebugMode()
public static boolean isDebugModeEnabled()
true
if the debug mode is enabled
true
if the debug mode is enabled;
false otherwise
public static void startGridSimulation(boolean debug) throws NullPointerException
debug
- true
if the visualizer is used or
false
otherwise.
NullPointerException
- This happens when creating this entity
before initialising GridSim package or this entity name is
null
or emptyinit(int, Calendar, boolean)
public static Visualizer getVisualizer()
public static boolean pauseSimulation()
true
if the simulation has been paused or
false
otherwise.public static boolean pauseSimulation(long time)
time
- the time when the simulation should be paused
true
if the simulation can be paused or
false
otherwise.public static boolean resumeSimulation()
true
if the simulation has been resumed or
false
otherwise.public static double clock()
Sim_system.clock()
public void gridSimHold(double duration)
duration
- the amount of time to holdpublic static void stopGridSimulation() throws NullPointerException
NullPointerException
- This happens when creating this entity
before initializing GridSim package or this entity name is
null or emptyinit(int, Calendar, boolean, String[], String[],
String)
,
Sim_system.run_stop()
protected Object receiveEventObject()
protected Object receiveEventObject(Sim_port sourcePort)
sourcePort
- a Sim_port object which is used to connect entities
for event passing
Sim_port
protected boolean gridletSubmit(Gridlet gl, int resID)
gl
- a Gridlet object to be sentresID
- an unique resource ID
protected boolean gridletSubmit(Gridlet gl, int resourceID, double delay, boolean ack)
gl
- a Gridlet object to be sentresourceID
- an unique resource IDdelay
- delay time or 0.0 if want to execute NOWack
- an acknowledgment status. true if want to
know the result of this method, false
otherwise or don't care.
Gridlet.isFinished()
,
gridletReceive()
protected boolean gridletSubmit(Gridlet gl, int resourceID, double delay, boolean ack, int netServiceLevel)
gl
- a Gridlet object to be sentresourceID
- an unique resource IDdelay
- delay time or 0.0 if want to execute NOWack
- 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.
Gridlet.isFinished()
,
gridletReceive()
protected Gridlet gridletReceive()
protected Gridlet gridletReceive(int gridletId, int userId, int resId)
gridletId
- a Gridlet IDuserId
- a user IDresId
- a grid resource ID
protected Gridlet gridletReceive(int gridletId, int resId)
gridletId
- a Gridlet IDresId
- a grid resource ID
protected Gridlet gridletCancel(Gridlet gl, int resourceId, double delay)
gl
- a Gridlet object to be canceledresourceId
- an unique resource IDdelay
- delay time or 0.0 if want to cancel NOW
protected Gridlet gridletCancel(int gridletId, int userId, int resourceId, double delay)
gridletId
- a Gridlet IDuserId
- the user or owner ID of this GridletresourceId
- an unique resource ID to which this Gridlet was
previously sent todelay
- delay time or 0.0 if want to cancel NOW
protected boolean gridletPause(Gridlet gl, int resId, double delay)
gl
- a Gridlet object to be sentresId
- an unique resource IDdelay
- delay time or 0.0 if want to execute NOW
gridletReceive()
protected boolean gridletPause(int gridletId, int userId, int resourceId, double delay, boolean ack)
gridletId
- a Gridlet IDuserId
- the user or owner ID of this GridletresourceId
- an unique resource IDdelay
- delay time or 0.0 if want to execute NOWack
- an acknowledgement, i.e. true if wanted to know
whether this operation is success or not, false
otherwise (don't care)
gridletReceive()
protected int gridletStatus(Gridlet gl, int resourceId)
gl
- a Gridlet objectresourceId
- a GridResource ID that executes this Gridlet object
Gridlet
protected int gridletStatus(int gridletId, int userId, int resourceId)
gridletId
- a Gridlet IDuserId
- the user or owner of this Gridlet objectresourceId
- a GridResource ID that executes this Gridlet object
Gridlet
protected boolean gridletResume(Gridlet gl, int resId, double delay)
gl
- a Gridlet object to be sentresId
- an unique resource IDdelay
- delay time or 0.0 if want to execute NOW
protected boolean gridletResume(int gridletId, int userId, int resourceId, double delay, boolean ack)
gridletId
- a Gridlet IDuserId
- the user or owner ID of this GridletresourceId
- an unique resource IDdelay
- delay time or 0.0 if want to execute NOWack
- an acknowledgement, i.e. true if wanted to know
whether this operation is success or not, false
otherwise (don't care)
protected boolean gridletMove(Gridlet gl, int srcId, int destId, double delay)
gl
- a Gridlet objectsrcId
- the GridResource ID that is currently executing this GridletdestId
- the new GridResource IDdelay
- simulation delay
gridletReceive()
protected boolean gridletMove(int gridletId, int userId, int srcId, int destId, double delay, boolean ack)
gridletId
- a Gridlet IDuserId
- the owner or user ID of this GridletsrcId
- the GridResource ID that is currently executing this
GridletdestId
- the new GridResource IDdelay
- simulation delayack
- an acknowledgement, i.e. true if wanted to know
whether this operation is success or not, false
otherwise (don't care)
gridletReceive()
public String getEntityName()
public static String getEntityName(int entityID)
entityID
- the entity ID
public static String getEntityName(Integer entityID)
entityID
- the entity ID
public static int getEntityId(String entityName)
entityName
- an Entity name
public static int getGridStatisticsEntityId()
public static int getGridInfoServiceEntityId()
public static int getGISId()
public static int getGridSimShutdownEntityId()
GridSimShutdown
protected void shutdownUserEntity()
GridSimShutdown
entity waits for all users
termination before shuting down other entities.
GridSimShutdown
protected void shutdownGridStatisticsEntity()
public static LinkedList getGridResourceList()
public static boolean resourceSupportAR(int resourceID)
resourceID
- a resource ID
public static boolean resourceSupportAR(Integer resourceID)
resourceID
- a resource ID
public static LinkedList getAdvancedReservationList()
public static boolean isResourceExist(int id)
id
- a GridResource id
public static boolean isResourceExist(Integer id)
id
- a GridResource id
public static boolean isTraceEnabled()
public int getNumPE(int resourceID)
resourceID
- a resource ID
public int getNumPE(Integer resourceID)
resourceID
- a resource ID
public int getNumFreePE(int resourceID)
resourceID
- a resource ID
public int getNumFreePE(Integer resourceID)
resourceID
- a resource ID
public ResourceCharacteristics getResourceCharacteristics(int resourceID)
PE
availability might
change over time.
Use getNumFreePE(int)
to determine number of free PE
at the time of a request instead.
resourceID
- the resource ID
ResourceCharacteristics
public Accumulator getResourceDynamicInfo(int resourceID)
resourceID
- the resource ID
public void recordStatistics(String category, double data)
category
- a category namedata
- a value to be recordedpublic void recordStatistics(String category, int data)
category
- a category namedata
- a value to be recordedpublic void recordStatistics(String category, String data)
category
- a category namedata
- a value to be recordedpublic void recordStatistics(String category, boolean data)
category
- a category namedata
- a value to be recordedpublic static boolean initNetworkType(int networkType)
GridSimCore.NETWORK_TYPE
to be used in
the simulation. By default, the GridSimCore.NETWORK_TYPE
is set to GridSimTags.NET_PACKET_LEVEL
.
networkType
- network type
GridSimCore.NETWORK_TYPE
,
GridSimTags.NET_PACKET_LEVEL
,
GridSimTags.NET_FLOW_LEVEL
,
GridSimTags.NET_BUFFER_PACKET_LEVEL
public static int getNetworkType()
GridSimCore.NETWORK_TYPE
,
GridSimTags.NET_PACKET_LEVEL
,
GridSimTags.NET_FLOW_LEVEL
,
GridSimTags.NET_BUFFER_PACKET_LEVEL
|
GridSim 5.0 beta | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |