GridSim
v3.1

gridsim
Class GridResource

Object
  extended byThread
      extended byeduni.simjava.Sim_entity
          extended bygridsim.GridSimCore
              extended bygridsim.GridResource
All Implemented Interfaces:
Cloneable, Runnable
Direct Known Subclasses:
ARGridResource

public class GridResource
extends GridSimCore

GridResource extends the GridSimCore class for gaining communication and concurrent entity capabilities. An instance of this class stimulates 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
See Also:
GridSimCore, ResourceCharacteristics, AllocPolicy
Invariant:
$none

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  ResourceCalendar resCalendar_
          a ResourceCalendar object
protected  ResourceCharacteristics resource_
          Characteristics of this resource
protected  int SIZE
          Integer object size, including its overhead
 
Fields inherited from class gridsim.GridSimCore
input, output
 
Fields inherited from class eduni.simjava.Sim_entity
 
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.
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.
 void SpaceShare_AllocatePEtoGridlet(Gridlet gl)
          Deprecated. As of GridSim 2.2, this method is OBSOLETE.
 void spaceShared_AllocatePEtoGridlet(Gridlet gl)
          Deprecated. As of GridSim 2.2, this method is OBSOLETE.
 
Methods inherited from class gridsim.GridSimCore
finalize, finalizeGridSimulation, getLink, getPingResult, isNetworked, IsNetworked, ping, ping, ping, ping, pingBlockingCall, pingBlockingCall, pingBlockingCall, pingBlockingCall, send, Send, send, Send, send, Send, send, Send, send, Send, send, Send, setBackgroundTraffic, setBackgroundTraffic, TerminateInputOutputEntities, terminateIOEntities
 
Methods inherited from class eduni.simjava.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, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class Object
equals, 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 final int SIZE
Integer object size, including its overhead

See Also:
Constant Field Values
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:
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:
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:
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:
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:
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:
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

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

SpaceShare_AllocatePEtoGridlet

public void SpaceShare_AllocatePEtoGridlet(Gridlet gl)
Deprecated. As of GridSim 2.2, this method is OBSOLETE.

As of GridSim 2.2, this method is OBSOLETE. Allocates one of the PEs to Gridlet for execution and schedules an internal event to be delivered at completion time.

Parameters:
gl - a Gridlet to be processed
Pre Condition:
gl != null
Post Condition:
$none

spaceShared_AllocatePEtoGridlet

public void spaceShared_AllocatePEtoGridlet(Gridlet gl)
Deprecated. As of GridSim 2.2, this method is OBSOLETE.

As of GridSim 2.2, this method is OBSOLETE. Allocates one of the PEs to Gridlet for execution and schedules an internal event to be delivered at completion time.

Parameters:
gl - a Gridlet to be processed
Pre Condition:
gl != null
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.

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
v3.1

The University of Melbourne, Australia, 2004