GridSim 5.0 beta

gridsim
Class GridResource

Object
  extended by Thread
      extended by Sim_entity
          extended by GridSimCore
              extended by GridResource
All Implemented Interfaces:
Cloneable, Runnable
Direct Known Subclasses:
ARGridResource, DataGridResource, ParallelResource

public class GridResource
extends GridSimCore

GridResource extends the GridSimCore class for gaining communication and concurrent entity capabilities. An instance of this class simulates a resource with properties defined in an object of ResourceCharacteristics class.

The process of creating a Grid resource is as follows:

  1. create PE (Processing Element) objects with a suitable MIPS (Million Instructions Per Second) or SPEC (Standard Performance Evaluation Corporation) rating;
  2. assemble them together to create a machine;
  3. group one or more objects of the machine to form a Grid resource

A resource having a single machine with one or more PEs (Processing Elements) is managed as a time-shared system using a round-robin scheduling algorithm. A resource with multiple machines is treated as a distributed memory cluster and is managed as a space-shared system using FCFS (First Come Firt Serve) scheduling policy or its variants.

Since GridSim 2.2, other scheduling algorithm can be added externally (without compiling or replacing the existing GridSim JAR file) into a Grid resource. For more information, look on tutorial page or AllocPolicy class.

Since GridSim 3.0, different types of resources can be created externally without modifying this class. You need to do the following:

  1. extends from this class
  2. uses only a constructor from GridResource(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicy)
  3. overrides registerOtherEntity() method to register a different entity or tag to GridInformationService. However, you also need to create a new child class extending from GridInformationService.
  4. overrides processOtherEvent(Sim_event) method to process other incoming tags apart from the standard ones.

NOTE:

Since GridSim 3.1, a network framework has been incorporated into this simulation. To make use of this, you need to create a resource entity only using the below constructors:

Then you need to attach this entity into the overall network topology, i.e. connecting this entity to a router, etc. See the examples for more details.

Since:
GridSim Toolkit 1.0
Author:
Manzur Murshed and Rajkumar Buyya, Anthony Sulistio (re-design and re-written this class)
See Also:
GridSimCore, ResourceCharacteristics, AllocPolicy
Invariant:
$none

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  AllocPolicy policy_
          A resource's scheduler.
protected  int policyType_
          A scheduler type of this resource, such as FCFS, Round Robin, etc
protected  String regionalGISName_
          Regional GIS entity name
protected  ResourceCalendar resCalendar_
          a ResourceCalendar object
protected  ResourceCharacteristics resource_
          Characteristics of this resource
protected static int SIZE
          Integer object size, including its overhead
 
Fields inherited from class GridSimCore
input, NETWORK_TYPE, output
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GridResource(String name, double baud_rate, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays)
          Allocates a new GridResource object.
GridResource(String name, double baud_rate, ResourceCharacteristics resource, ResourceCalendar calendar)
          Allocates a new GridResource object.
GridResource(String name, double baud_rate, ResourceCharacteristics resource, ResourceCalendar calendar, AllocPolicy policy)
          Allocates a new GridResource object.
GridResource(String name, Link link, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays)
          Allocates a new GridResource object.
GridResource(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar)
          Allocates a new GridResource object.
GridResource(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar, AllocPolicy policy)
          Allocates a new GridResource object.
 
Method Summary
 void body()
          Handles external events that are coming to this GridResource entity.
 AllocPolicy getAllocationPolicy()
          Returns the allocation policy used by this Grid resource.
 ResourceCharacteristics getResourceCharacteristics()
          Returns the characteristics of the resource.
protected  void processOtherEvent(Sim_event ev)
          Overrides this method when making a new and different type of resource.
protected  void registerOtherEntity()
          Overrides this method when making a new and different type of resource.
 boolean setRegionalGIS(AbstractGIS gis)
          Sets a regional GridInformationService (GIS) entity for this resource to communicate with.
 boolean setRegionalGIS(String regionalGIS)
          Sets a regional GridInformationService (GIS) entity for this resource to communicate with.
 
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
 

Field Detail

resource_

protected ResourceCharacteristics resource_
Characteristics of this resource


resCalendar_

protected ResourceCalendar resCalendar_
a ResourceCalendar object


policy_

protected AllocPolicy policy_
A resource's scheduler. This object is reponsible in scheduling and and executing submitted Gridlets.


policyType_

protected int policyType_
A scheduler type of this resource, such as FCFS, Round Robin, etc


SIZE

protected static final int SIZE
Integer object size, including its overhead

See Also:
Constant Field Values

regionalGISName_

protected String regionalGISName_
Regional GIS entity name

Constructor Detail

GridResource

public GridResource(String name,
                    double baud_rate,
                    long seed,
                    ResourceCharacteristics resource,
                    double peakLoad,
                    double offPeakLoad,
                    double relativeHolidayLoad,
                    LinkedList weekends,
                    LinkedList holidays)
             throws Exception
Allocates a new GridResource object. When making a different type of GridResource object, use GridResource(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicy) and then overrides processOtherEvent(Sim_event).

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
baud_rate - network communication or bandwidth speed
seed - the initial seed
resource - an object of ResourceCharacteristics
peakLoad - the load during peak times
offPeakLoad - the load during off peak times
relativeHolidayLoad - the load during holiday times
weekends - a linked-list contains the weekend days
holidays - a linked-list contains the public holidays
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String), GridSim.init(int, Calendar, boolean), GridResource(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicy)
Pre Condition:
name != null, baud_rate > 0, resource != null
Post Condition:
$none

GridResource

public GridResource(String name,
                    double baud_rate,
                    ResourceCharacteristics resource,
                    ResourceCalendar calendar)
             throws Exception
Allocates a new GridResource object. When making a different type of GridResource object, use GridResource(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicy) and then overrides processOtherEvent(Sim_event).

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
baud_rate - network communication or bandwidth speed
resource - an object of ResourceCharacteristics
calendar - an object of ResourceCalendar
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String), GridSim.init(int, Calendar, boolean), GridResource(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicy)
Pre Condition:
name != null, baud_rate > 0, resource != null, calendar != null
Post Condition:
$none

GridResource

public GridResource(String name,
                    double baud_rate,
                    ResourceCharacteristics resource,
                    ResourceCalendar calendar,
                    AllocPolicy policy)
             throws Exception
Allocates a new GridResource object. When making a different type of GridResource object, use this constructor and then overrides processOtherEvent(Sim_event).

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
baud_rate - network communication or bandwidth speed
resource - an object of ResourceCharacteristics
calendar - an object of ResourceCalendar
policy - a scheduling policy for this Grid resource. If no scheduling policy is defined, the default one is SpaceShared
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String), GridSim.init(int, Calendar, boolean), AllocPolicy
Pre Condition:
name != null, baud_rate > 0, resource != null, calendar != null, policy != null
Post Condition:
$none

GridResource

public GridResource(String name,
                    Link link,
                    long seed,
                    ResourceCharacteristics resource,
                    double peakLoad,
                    double offPeakLoad,
                    double relativeHolidayLoad,
                    LinkedList weekends,
                    LinkedList holidays)
             throws Exception
Allocates a new GridResource object. When making a different type of GridResource object, use GridResource(String, Link, ResourceCharacteristics, ResourceCalendar, AllocPolicy) and then overrides processOtherEvent(Sim_event).

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
link - the link that will be used to connect this GridResource to another Entity or Router.
seed - the initial seed
resource - an object of ResourceCharacteristics
peakLoad - the load during peak times
offPeakLoad - the load during off peak times
relativeHolidayLoad - the load during holiday times
weekends - a linked-list contains the weekend days
holidays - a linked-list contains the public holidays
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
name != null, link != null, resource != null
Post Condition:
$none

GridResource

public GridResource(String name,
                    Link link,
                    ResourceCharacteristics resource,
                    ResourceCalendar calendar)
             throws Exception
Allocates a new GridResource object. When making a different type of GridResource object, use GridResource(String, Link, ResourceCharacteristics, ResourceCalendar, AllocPolicy) and then overrides processOtherEvent(Sim_event).

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
link - the link that will be used to connect this GridResource to another Entity or Router.
resource - an object of ResourceCharacteristics
calendar - an object of ResourceCalendar
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
name != null, link != null, resource != null, calendar != null
Post Condition:
$none

GridResource

public GridResource(String name,
                    Link link,
                    ResourceCharacteristics resource,
                    ResourceCalendar calendar,
                    AllocPolicy policy)
             throws Exception
Allocates a new GridResource object. When making a different type of GridResource object, use this constructor and then overrides processOtherEvent(Sim_event).

Parameters:
name - the name to be associated with this entity (as required by Sim_entity class from simjava package)
link - the link that will be used to connect this GridResource to another Entity or Router.
resource - an object of ResourceCharacteristics
calendar - an object of ResourceCalendar
policy - a scheduling policy for this Grid resource. If no scheduling policy is defined, the default one is SpaceShared
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initializing GridSim package
  • this entity name is null or empty
  • this entity has zero number of PEs (Processing Elements).
    No PEs mean the Gridlets can't be processed. A GridResource must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String), AllocPolicy
Pre Condition:
name != null, link != null, resource != null, calendar != null, policy != null
Post Condition:
$none
Method Detail

getAllocationPolicy

public AllocPolicy getAllocationPolicy()
Returns the allocation policy used by this Grid resource.

Returns:
the allocation policy

getResourceCharacteristics

public ResourceCharacteristics getResourceCharacteristics()
Returns the characteristics of the resource.

Returns:
the resource characteristics

setRegionalGIS

public boolean setRegionalGIS(String regionalGIS)
Sets a regional GridInformationService (GIS) entity for this resource to communicate with. This resource will then register its ID to the regional GIS entity, rather than GridInformationService or system GIS.

Parameters:
regionalGIS - name of regional GIS entity
Returns:
true if it is successful, false otherwise
Pre Condition:
regionalGIS != null
Post Condition:
$none

setRegionalGIS

public boolean setRegionalGIS(AbstractGIS gis)
Sets a regional GridInformationService (GIS) entity for this resource to communicate with. This resource will then register its ID to the regional GIS entity, rather than GridInformationService or system GIS.

Parameters:
gis - regional GIS entity object
Returns:
true if it is successful, false otherwise
Pre Condition:
gis != null
Post Condition:
$none

body

public void body()
Handles external events that are coming to this GridResource entity. This method also registers the identity of this GridResource entity to GridInformationService class.

The services or tags available for this resource are:


This method also calls these methods in the following order:
  1. registerOtherEntity() method
  2. processOtherEvent(Sim_event) method

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

processOtherEvent

protected void processOtherEvent(Sim_event ev)
Overrides this method when making a new and different type of resource. This method is called by body() for incoming unknown tags.

Another approach is to override the AllocPolicy.processOtherEvent(Sim_event) method. This approach is desirable if you do not want to create a new type of grid resource.

Parameters:
ev - a Sim_event object
Pre Condition:
ev != null
Post Condition:
$none

registerOtherEntity

protected void registerOtherEntity()
Overrides this method when making a new and different type of resource. This method is called by body() to register other type to GridInformationService entity. In doing so, you need to create a new child class extending from GridInformationService.
NOTE: You do not need to override body() method, if you use this method.

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

GridSim 5.0 beta

The University of Melbourne, Australia, 2009