GridSim 5.0 beta

gridsim.resFailure
Class GridResourceWithFailure

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

public class GridResourceWithFailure
extends GridSimCore

GridResourceWithFailure is based on GridResource, but with added failure functionalities. GridResourceWithFailure 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.

Since:
GridSim Toolkit 4.1
Author:
Agustin Caminero and Anthony Sulistio
See Also:
GridResource, ResourceCharacteristics, AllocPolicyWithFailure
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  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
GridResourceWithFailure(String name, double baud_rate, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays)
          Allocates a new GridResourceWithFailure object.
GridResourceWithFailure(String name, double baud_rate, ResourceCharacteristics resource, ResourceCalendar calendar)
          Allocates a new GridResourceWithFailure object.
GridResourceWithFailure(String name, double baud_rate, ResourceCharacteristics resource, ResourceCalendar calendar, AllocPolicyWithFailure policy)
          Allocates a new GridResourceWithFailure object.
GridResourceWithFailure(String name, Link link, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays)
          Allocates a new GridResourceWithFailure object.
GridResourceWithFailure(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar)
          Allocates a new GridResourceWithFailure object.
GridResourceWithFailure(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar, AllocPolicyWithFailure policy)
          Allocates a new GridResourceWithFailure object.
 
Method Summary
 void body()
          Handles external events that are coming to this GridResourceWithFailure 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.
 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.
 void setTrace(boolean trace)
          Asks this resource to record its activities.
protected  void write(String event, int numMachines)
          Write an event of this entity into a file.
 
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 responsible for 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

regionalGISName_

protected String regionalGISName_
Regional GIS entity name

Constructor Detail

GridResourceWithFailure

public GridResourceWithFailure(String name,
                               double baud_rate,
                               long seed,
                               ResourceCharacteristics resource,
                               double peakLoad,
                               double offPeakLoad,
                               double relativeHolidayLoad,
                               LinkedList weekends,
                               LinkedList holidays)
                        throws Exception
Allocates a new GridResourceWithFailure object. When making a different type of GridResourceWithFailure object, use GridResourceWithFailure(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) 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 GridResourceWithFailure 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), GridResourceWithFailure(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure)
Pre Condition:
name != null, baud_rate > 0, resource != null
Post Condition:
$none

GridResourceWithFailure

public GridResourceWithFailure(String name,
                               double baud_rate,
                               ResourceCharacteristics resource,
                               ResourceCalendar calendar)
                        throws Exception
Allocates a new GridResourceWithFailure object. When making a different type of GridResourceWithFailure object, use GridResourceWithFailure(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) 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 GridResourceWithFailure 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), GridResourceWithFailure(String, double, ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure)
Pre Condition:
name != null, baud_rate > 0, resource != null, calendar != null
Post Condition:
$none

GridResourceWithFailure

public GridResourceWithFailure(String name,
                               double baud_rate,
                               ResourceCharacteristics resource,
                               ResourceCalendar calendar,
                               AllocPolicyWithFailure policy)
                        throws Exception
Allocates a new GridResourceWithFailure object. When making a different type of GridResourceWithFailure 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 GridResourceWithFailure 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), AllocPolicyWithFailure
Pre Condition:
name != null, baud_rate > 0, resource != null, calendar != null, policy != null
Post Condition:
$none

GridResourceWithFailure

public GridResourceWithFailure(String name,
                               Link link,
                               long seed,
                               ResourceCharacteristics resource,
                               double peakLoad,
                               double offPeakLoad,
                               double relativeHolidayLoad,
                               LinkedList weekends,
                               LinkedList holidays)
                        throws Exception
Allocates a new GridResourceWithFailure object. When making a different type of GridResourceWithFailure object, use GridResourceWithFailure(String, Link, ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) 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 GridResourceWithFailure 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 GridResourceWithFailure 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

GridResourceWithFailure

public GridResourceWithFailure(String name,
                               Link link,
                               ResourceCharacteristics resource,
                               ResourceCalendar calendar)
                        throws Exception
Allocates a new GridResourceWithFailure object. When making a different type of GridResourceWithFailure object, use GridResourceWithFailure(String, Link, ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) 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 GridResourceWithFailure 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 GridResourceWithFailure 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

GridResourceWithFailure

public GridResourceWithFailure(String name,
                               Link link,
                               ResourceCharacteristics resource,
                               ResourceCalendar calendar,
                               AllocPolicyWithFailure policy)
                        throws Exception
Allocates a new GridResourceWithFailure object. When making a different type of GridResourceWithFailure 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 GridResourceWithFailure 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 GridResourceWithFailure must contain one or more Machines. A Machine must contain one or more PEs.
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String), AllocPolicyWithFailure
Pre Condition:
name != null, link != null, resource != null, calendar != null, policy != null
Post Condition:
$none
Method Detail

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

setTrace

public void setTrace(boolean trace)
Asks this resource to record its activities.
NOTE: this method should be called BEFORE the simulation starts. If an existing file exists, the new activities will be appended at the end. The file name is this entity name.

Parameters:
trace - true if you want to record this resource's activities, false otherwise

body

public void body()
Handles external events that are coming to this GridResourceWithFailure entity. This method also registers the identity of this GridResourceWithFailure 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

write

protected void write(String event,
                     int numMachines)
Write an event of this entity into a file. If an existing file exists, the new event will be appended at the end. The file name is this entity name.

Parameters:
event - Values: "Removing" or "Registering" a resource
numMachines - number of failed machines

GridSim 5.0 beta

The University of Melbourne, Australia, 2009