GridSim 5.0 beta

gridsim.parallel.reservation
Class ReservationRequester

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

public class ReservationRequester
extends GridSim

This class represents an entity that makes advance reservation requests. This entity initiates operations such as such as create, modify, cancel and query.

Since:
5.0
Author:
Marcos Dias de Assuncao

Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class GridSim
GRIDSIM_VERSION_STRING, PAUSE
 
Fields inherited from class GridSimCore
input, NETWORK_TYPE, output
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected ReservationRequester(String name, double baudRate)
          Allocates a new object.
protected ReservationRequester(String name, Link link)
          Allocates a new object.
 
Method Summary
 boolean cancelReservation(int reservationId)
          Cancels a given reservation.
 boolean commitReservation(int reservId)
          Commits a reservation indicating that the user is willing to used it.
 Reservation createReservation(double startTime, int duration, int numPE, int resID)
          Creates a new reservation and sends the request to a resource.
Immediate reservation can be used by this method by specifying startTime = 0, meaning do not care about start time or use current time as a reservation's start time.
protected  Reservation getReservation(int reservationId)
          Gets a reservation object based on the given booking ID
 Reservation modifyReservation(int reservationId, double startTime, int duration, int numPE)
          Modifies an existing reservation.
 Collection<TimeSlot> queryFreeTime(double startTime, int duration, int resID)
          Queries to a resource regarding to list of free time during a period of time.
 ReservationStatus queryReservation(int reservationId)
          Queries the overall status of a reservation.
protected  ReservationMessage sendReservationMessage(ReservationMessage message)
          Sends a reservation message and waits for a response.
 
Methods inherited from class GridSim
clock, disableDebugMode, enableDebugMode, getAdvancedReservationList, getEntityId, getEntityName, getEntityName, getEntityName, getGISId, getGridInfoServiceEntityId, getGridResourceList, getGridSimShutdownEntityId, getGridStatisticsEntityId, getNetworkType, getNumFreePE, getNumFreePE, getNumPE, getNumPE, getResourceCharacteristics, getResourceDynamicInfo, getSimulationCalendar, getSimulationStartDate, getVisualizer, gridletCancel, gridletCancel, gridletMove, gridletMove, gridletPause, gridletPause, gridletReceive, gridletReceive, gridletReceive, gridletResume, gridletResume, gridletStatus, gridletStatus, gridletSubmit, gridletSubmit, gridletSubmit, gridSimHold, init, init, init, initNetworkType, isDebugModeEnabled, isResourceExist, isResourceExist, isTraceEnabled, pauseSimulation, pauseSimulation, receiveEventObject, receiveEventObject, recordStatistics, recordStatistics, recordStatistics, recordStatistics, resourceSupportAR, resourceSupportAR, resumeSimulation, setGIS, shutdownGridStatisticsEntity, shutdownUserEntity, startGridSimulation, startGridSimulation, stopGridSimulation
 
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, body, 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
 

Constructor Detail

ReservationRequester

protected ReservationRequester(String name,
                               double baudRate)
                        throws Exception
Allocates a new object.

Parameters:
name - this entity name
baudRate - the bandwidth of this entity
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initialising GridSim package
  • this entity name is null or empty
Pre Condition:
name != null, baudRate > 0
Post Condition:
$none

ReservationRequester

protected ReservationRequester(String name,
                               Link link)
                        throws Exception
Allocates a new object.

Parameters:
name - this entity name
link - the link that this GridSim entity will use to communicate with other GridSim or Network entities.
Throws:
Exception - This happens when one of the following scenarios occur:
  • creating this entity before initialising GridSim package
  • this entity name is null or empty
Pre Condition:
name != null, link != null
Post Condition:
$none
Method Detail

getReservation

protected Reservation getReservation(int reservationId)
Gets a reservation object based on the given booking ID

Parameters:
reservationId - a reservation booking ID
Returns:
Reservation object or null if an error occurs

createReservation

public Reservation createReservation(double startTime,
                                     int duration,
                                     int numPE,
                                     int resID)
Creates a new reservation and sends the request to a resource.
Immediate reservation can be used by this method by specifying startTime = 0, meaning do not care about start time or use current time as a reservation's start time.

Parameters:
startTime - reservation start time in seconds
duration - reservation end time in seconds
numPE - number of PEs required for this reservation
resID - a resource ID
Returns:
an unique booking id if successful, otherwise an error message
Pre Condition:
startTime >= 0, duration > 0, numPE > 0, resID > 0

cancelReservation

public boolean cancelReservation(int reservationId)
Cancels a given reservation. All jobs associated with this reservation will automatically be cancelled.

Parameters:
reservationId - the id of the reservation to be cancelled
Returns:
a boolean that denotes success or failure.

queryFreeTime

public Collection<TimeSlot> queryFreeTime(double startTime,
                                          int duration,
                                          int resID)
Queries to a resource regarding to list of free time during a period of time. This method returns a list that contains the availability of PEs at simulation times between the start and end time. Each entry contains:

Parameters:
resID - a resource ID
startTime - the simulation start time in which the requester is interested
duration - duration time in seconds
Returns:
a list of entries that describe the ranges of PEs available at simulation time between the requested time
Pre Condition:
resourceID > 0, startTime >= 0, finishTime > 0

queryReservation

public ReservationStatus queryReservation(int reservationId)
Queries the overall status of a reservation.

Parameters:
reservationId - this reservation booking ID
Returns:
an integer tag that denotes success or failure.

commitReservation

public boolean commitReservation(int reservId)
Commits a reservation indicating that the user is willing to used it.

Parameters:
reservId - a reservation booking ID
Returns:
true if commit was successful; false otherwise.

modifyReservation

public Reservation modifyReservation(int reservationId,
                                     double startTime,
                                     int duration,
                                     int numPE)
Modifies an existing reservation. Modification must be done before reservation's start time.

Parameters:
reservationId - reservation booking Id
startTime - reservation start time in seconds
duration - reservation end time in seconds
numPE - number of PEs required for this reservation
Returns:
a reservation object containing the new reservation or null if an error happened during the request

sendReservationMessage

protected ReservationMessage sendReservationMessage(ReservationMessage message)
Sends a reservation message and waits for a response.

Parameters:
message - the message to be sent
Returns:
the response message

GridSim 5.0 beta

The University of Melbourne, Australia, 2009