GridSim 5.0 beta

gridsim.resFailure
Class RegionalGISWithFailure

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

public class RegionalGISWithFailure
extends AbstractGIS

RegionalGISWithFailure is based on RegionalGIS, but with added failure functionalities. RegionalGISWithFailure is a simple regional GridInformationService (GIS) entity that performs basic functionalities, such as storing a list of local resources, and asking other regional GIS entities for resources.

If you want to implement other complex functionalities, you need to extend this class and to override processOtherEvent(Sim_event) and/or registerOtherEntity() method.

Since:
GridSim Toolkit 4.1
Author:
Agustin Caminero and Anthony Sulistio
See Also:
RegionalGIS

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  Integer myID_
          This entity ID in Integer object.
 
Fields inherited from class AbstractGIS
GIS_INQUIRY_RESOURCE_AR_LIST, GIS_INQUIRY_RESOURCE_AR_RESULT, GIS_INQUIRY_RESOURCE_LIST, GIS_INQUIRY_RESOURCE_RESULT, INQUIRY_GLOBAL_RESOURCE_AR_LIST, INQUIRY_GLOBAL_RESOURCE_LIST, INQUIRY_LOCAL_RESOURCE_AR_LIST, INQUIRY_LOCAL_RESOURCE_LIST, INQUIRY_REGIONAL_GIS, NOTIFY_GIS_RESOURCE_FAILURE, REGISTER_REGIONAL_GIS, REGISTER_RESOURCE, REGISTER_RESOURCE_AR, systemGIS_
 
Fields inherited from class GridSimCore
input, NETWORK_TYPE, output
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RegionalGISWithFailure(String name, Link link, ContinuousGenerator failureNumResPattern, ContinuousGenerator failureTimePattern, ContinuousGenerator failureLengthPattern)
          Creates a new regional GIS entity
RegionalGISWithFailure(String name, Link link, DiscreteGenerator failureNumResPattern, DiscreteGenerator failureTimePattern, DiscreteGenerator failureLengthPattern)
          Creates a new regional GIS entity
RegionalGISWithFailure(String name, Link link, Variate failureNumResPattern, Variate failureTimePattern, Variate failureLengthPattern)
          Creates a new regional GIS entity
 
Method Summary
protected  boolean getListFromOtherRegional(List regionalList, int eventTag)
          Get a list of IDs specified in the eventTag from other regional GIS
protected  double getNextFailureLengthSample()
          This function returns the following sample for the time when resources will fail.
protected  double getNextFailureNumResSample()
          This function returns the next sample for the number of resources which will fail.
protected  double getNextFailureTimeSample()
          This function returns the next sample for the time when resources will fail.
protected  double getNextNumMachinesFailedSample()
          This function returns the following sample for the number of machines which will fail in a resource.
protected  boolean pollResource(int resID)
          This function is to poll the resources in order to check whether they are failed or not
protected  AvailabilityInfo pollReturn()
          This function is to receive back the polls from the resources
protected  void processEndSimulation()
          Informs the registered entities regarding to the end of a simulation.
NOTE: This method can be overridden by its subclasses, provided that they call this method first.
protected  void processGISResourceARList(Sim_event ev)
          Process an incoming request from other GIS entities about getting a list of resource IDs supporting Advanced Reservation, that are registered to this regional GIS entity.
protected  void processGISResourceARResult(Sim_event ev)
          Process an incoming delivery from other GIS entities about their resource list supporting Advanced Reservation.
protected  void processGISResourceList(Sim_event ev)
          Process an incoming request from other GIS entities about getting a list of resource IDs, that are registered to this regional GIS entity.
protected  void processGISResourceResult(Sim_event ev)
          Process an incoming delivery from other GIS entities about their resource list.
protected  void processGlobalResourceARList(Sim_event ev)
          Process an incoming request about getting a list of resource IDs supporting Advanced Reservation that are registered in other regional GIS entities.
protected  void processGlobalResourceList(Sim_event ev)
          Process an incoming request from users about getting a list of resource IDs, that are registered in other regional GIS entities.
protected  void processInquiryRegionalGIS(Sim_event ev)
          Process an incoming request about getting a list of regional GIS IDs (including this entity ID), that are registered to the GridInformationService or system GIS.
protected  void processOtherEvent(Sim_event ev)
          Process an incoming request that uses a user-defined tag.
protected  void processRegisterResource(Sim_event ev)
          Process a registration request from a resource entity to this regional GIS entity.
protected  void processRegisterResourceAR(Sim_event ev)
          Process a registration request from a resource entity supporting Advanced Reservation to this regional GIS entity.
protected  void processResourceARList(Sim_event ev)
          Process an incoming request about getting a list of resource IDs supporting Advanced Reservation that are registered to this regional GIS entity.
protected  void processResourceList(Sim_event ev)
          Process an incoming request about getting a list of resource IDs that are registered to this regional GIS entity.
protected  void registerOtherEntity()
          Registers other information to GridInformationService or system GIS.
NOTE: This method can be overridden by its subclasses, provided that they call this method first.
protected  LinkedList requestFromSystemGIS()
          Asks from GridInformationService or system GIS about a list of regional GIS entity ID.
protected  boolean requestFromSystemGIS(int eventTag, List list)
          Asks from GridInformationService or system GIS about a specific event or request.
protected  boolean sendListToSender(int senderID, int tag, List list)
          Sends a list to sender
 boolean setFailureGenerator(ContinuousGenerator failureNumResPattern, ContinuousGenerator failureTimePattern, ContinuousGenerator failureLengthPattern)
          Sets failure generators for this entity.
 boolean setFailureGenerator(DiscreteGenerator failureNumResPattern, DiscreteGenerator failureTimePattern, DiscreteGenerator failureLengthPattern)
          Sets failure generators for this entity.
 boolean setFailureGenerator(Variate failureNumResPattern, Variate failureTimePattern, Variate failureLengthPattern)
          Sets failure generators for this entity.
 void setTrace(boolean trace)
          Asks this resource to record its activities.
protected  boolean storeRegistrationID(Sim_event ev, List list)
          Stores the incoming registration ID into the given list.
protected  void write(String event, int resID, double clock)
          Write an event of this entity into a file.
 
Methods inherited from class AbstractGIS
body, notifySystemGIS
 
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

myID_

protected Integer myID_
This entity ID in Integer object.

Constructor Detail

RegionalGISWithFailure

public RegionalGISWithFailure(String name,
                              Link link,
                              DiscreteGenerator failureNumResPattern,
                              DiscreteGenerator failureTimePattern,
                              DiscreteGenerator failureLengthPattern)
                       throws Exception
Creates a new regional GIS entity

Parameters:
name - this regional GIS name
link - a network link to this entity
failureLengthPattern - defines on how long each resource will be out of order
failureNumResPattern - defines on how many resource fails
failureTimePattern - defines on when each resource will fail
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
Pre Condition:
name != null, link != null
Post Condition:
$none

RegionalGISWithFailure

public RegionalGISWithFailure(String name,
                              Link link,
                              ContinuousGenerator failureNumResPattern,
                              ContinuousGenerator failureTimePattern,
                              ContinuousGenerator failureLengthPattern)
                       throws Exception
Creates a new regional GIS entity

Parameters:
name - this regional GIS name
link - a network link to this entity
failureLengthPattern - defines on how long each resource will be out of order
failureNumResPattern - defines on how many resource fails
failureTimePattern - defines on when each resource will fail
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
Pre Condition:
name != null, link != null
Post Condition:
$none

RegionalGISWithFailure

public RegionalGISWithFailure(String name,
                              Link link,
                              Variate failureNumResPattern,
                              Variate failureTimePattern,
                              Variate failureLengthPattern)
                       throws Exception
Creates a new regional GIS entity

Parameters:
name - this regional GIS name
link - a network link to this entity
failureLengthPattern - defines on how long each resource will be out of order
failureNumResPattern - defines on how many resource fails
failureTimePattern - defines on when each resource will fail
Throws:
Exception - This happens when creating this entity before initializing GridSim package or this entity name is null or empty
Pre Condition:
name != null, link != null
Post Condition:
$none
Method Detail

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

storeRegistrationID

protected boolean storeRegistrationID(Sim_event ev,
                                      List list)
Stores the incoming registration ID into the given list.
NOTE: ev.get_data() should contain an Integer object.

Parameters:
ev - a new Sim_event object or incoming registration request
list - a list storing the registration IDs
Returns:
true if successful, false otherwise
Pre Condition:
ev != null, list != null
Post Condition:
$none

processRegisterResourceAR

protected void processRegisterResourceAR(Sim_event ev)
Process a registration request from a resource entity supporting Advanced Reservation to this regional GIS entity.
NOTE: ev.get_data() should contain an Integer object representing the resource ID.

Specified by:
processRegisterResourceAR in class AbstractGIS
Parameters:
ev - a Sim_event object (or a registration request)
Pre Condition:
ev != null
Post Condition:
$none

processRegisterResource

protected void processRegisterResource(Sim_event ev)
Process a registration request from a resource entity to this regional GIS entity.
NOTE: ev.get_data() should contain an Integer object representing the resource ID.

Specified by:
processRegisterResource in class AbstractGIS
Parameters:
ev - a Sim_event object (or a registration request)
Pre Condition:
ev != null
Post Condition:
$none

write

protected void write(String event,
                     int resID,
                     double clock)
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
resID - resource id
clock - Current time

processOtherEvent

protected void processOtherEvent(Sim_event ev)
Process an incoming request that uses a user-defined tag.
NOTE: This method can be overridden by its subclasses, provided that they call this method first. This is required, just in case this method is not empty.

Specified by:
processOtherEvent in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processGISResourceList

protected void processGISResourceList(Sim_event ev)
Process an incoming request from other GIS entities about getting a list of resource IDs, that are registered to this regional GIS entity.

Specified by:
processGISResourceList in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processGISResourceARList

protected void processGISResourceARList(Sim_event ev)
Process an incoming request from other GIS entities about getting a list of resource IDs supporting Advanced Reservation, that are registered to this regional GIS entity.

Specified by:
processGISResourceARList in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processGISResourceARResult

protected void processGISResourceARResult(Sim_event ev)
Process an incoming delivery from other GIS entities about their resource list supporting Advanced Reservation.
NOTE: ev.get_data() should contain List containing resource IDs (in Integer object).

Specified by:
processGISResourceARResult in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processGISResourceResult

protected void processGISResourceResult(Sim_event ev)
Process an incoming delivery from other GIS entities about their resource list.
NOTE: ev.get_data() should contain List containing resource IDs (in Integer object).

Specified by:
processGISResourceResult in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processInquiryRegionalGIS

protected void processInquiryRegionalGIS(Sim_event ev)
Process an incoming request about getting a list of regional GIS IDs (including this entity ID), that are registered to the GridInformationService or system GIS.

Specified by:
processInquiryRegionalGIS in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processGlobalResourceARList

protected void processGlobalResourceARList(Sim_event ev)
Process an incoming request about getting a list of resource IDs supporting Advanced Reservation that are registered in other regional GIS entities.

Specified by:
processGlobalResourceARList in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processGlobalResourceList

protected void processGlobalResourceList(Sim_event ev)
Process an incoming request from users about getting a list of resource IDs, that are registered in other regional GIS entities.

Specified by:
processGlobalResourceList in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

getListFromOtherRegional

protected boolean getListFromOtherRegional(List regionalList,
                                           int eventTag)
Get a list of IDs specified in the eventTag from other regional GIS

Parameters:
regionalList - a list of regional GIS IDs
eventTag - an event tag or type of request
Returns:
true if successful, false otherwise
Pre Condition:
regionalList != null
Post Condition:
$none

requestFromSystemGIS

protected LinkedList requestFromSystemGIS()
Asks from GridInformationService or system GIS about a list of regional GIS entity ID.

Returns:
a list of regional GIS entity ID
Pre Condition:
$none
Post Condition:
$none

requestFromSystemGIS

protected boolean requestFromSystemGIS(int eventTag,
                                       List list)
Asks from GridInformationService or system GIS about a specific event or request.

Parameters:
eventTag - an event tag or type of request
list - a list storing the results
Returns:
true if successful, false otherwise
Pre Condition:
list != null
Post Condition:
$none

sendListToSender

protected boolean sendListToSender(int senderID,
                                   int tag,
                                   List list)
Sends a list to sender

Parameters:
senderID - the sender ID
tag - an event tag
list - a list to be sent to
Returns:
true if successful, false otherwise
Pre Condition:
senderID != -1
Post Condition:
$none

processResourceList

protected void processResourceList(Sim_event ev)
Process an incoming request about getting a list of resource IDs that are registered to this regional GIS entity.

Specified by:
processResourceList in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

processResourceARList

protected void processResourceARList(Sim_event ev)
Process an incoming request about getting a list of resource IDs supporting Advanced Reservation that are registered to this regional GIS entity.

Specified by:
processResourceARList in class AbstractGIS
Parameters:
ev - a Sim_event object (or an incoming event or request)
Pre Condition:
ev != null
Post Condition:
$none

registerOtherEntity

protected void registerOtherEntity()
Registers other information to GridInformationService or system GIS.
NOTE: This method can be overridden by its subclasses, provided that they call this method first. This is required, just in case this method is not empty.

Specified by:
registerOtherEntity in class AbstractGIS
Pre Condition:
$none
Post Condition:
$none

processEndSimulation

protected void processEndSimulation()
Informs the registered entities regarding to the end of a simulation.
NOTE: This method can be overridden by its subclasses, provided that they call this method first. This is required, just in case this method is not empty.

Specified by:
processEndSimulation in class AbstractGIS
Pre Condition:
$none
Post Condition:
$none

setFailureGenerator

public boolean setFailureGenerator(DiscreteGenerator failureNumResPattern,
                                   DiscreteGenerator failureTimePattern,
                                   DiscreteGenerator failureLengthPattern)
Sets failure generators for this entity.

Parameters:
failureNumResPattern - to decide on how many resources will fail
failureTimePattern - to decide on when the fail will be
failureLengthPattern - to decide on how long the fail will be
Returns:
true if successful, false otherwise

setFailureGenerator

public boolean setFailureGenerator(ContinuousGenerator failureNumResPattern,
                                   ContinuousGenerator failureTimePattern,
                                   ContinuousGenerator failureLengthPattern)
Sets failure generators for this entity.

Parameters:
failureNumResPattern - to decide on how many resources will fail
failureTimePattern - to decide on when the fail will be
failureLengthPattern - to decide on how long the fail will be
Returns:
true if successful, false otherwise

setFailureGenerator

public boolean setFailureGenerator(Variate failureNumResPattern,
                                   Variate failureTimePattern,
                                   Variate failureLengthPattern)
Sets failure generators for this entity.

Parameters:
failureNumResPattern - to decide on how many resources will fail
failureTimePattern - to decide on when the fail will be
failureLengthPattern - to decide on how long the fail will be
Returns:
true if successful, false otherwise

getNextFailureNumResSample

protected double getNextFailureNumResSample()
This function returns the next sample for the number of resources which will fail. We take into account whether the pattern for this value is discrete or continuous.

Returns:
the sample for the number of resources which will fail

getNextFailureTimeSample

protected double getNextFailureTimeSample()
This function returns the next sample for the time when resources will fail. We take into account whether the pattern for this value is discrete or continuous.

Returns:
the sample for the time when resources will fail

getNextFailureLengthSample

protected double getNextFailureLengthSample()
This function returns the following sample for the time when resources will fail. We take into account whether the pattern for this value is discrete or continuous.

Returns:
the sample for the time when resources will fail

getNextNumMachinesFailedSample

protected double getNextNumMachinesFailedSample()
This function returns the following sample for the number of machines which will fail in a resource. We reuse the same pattern used for the number of resources which will fail. We take into account whether the pattern for this value is discrete or continuous.

Returns:
the sample for the number of machines which will fail in a resource

pollResource

protected boolean pollResource(int resID)
This function is to poll the resources in order to check whether they are failed or not

Returns:
true if everything works well

pollReturn

protected AvailabilityInfo pollReturn()
This function is to receive back the polls from the resources

Returns:
a AvailabilityInfo object

GridSim 5.0 beta

The University of Melbourne, Australia, 2009