GridSim 5.0 beta

gridsim
Class ResourceCalendar

Object
  extended by ResourceCalendar

public class ResourceCalendar
extends Object

GridSim ResourceCalendar class implements a mechanism to support modeling a local load on Grid resources that may vary according to the time zone, time, weekends and holidays.

Since:
GridSim Toolkit 1.0
Author:
Manzur Murshed and Rajkumar Buyya
Invariant:
$none

Constructor Summary
ResourceCalendar(double[] regularLoad, double timeZone, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekendList, LinkedList holidayList, long seed)
          Allocates a new ResourceCalendar object with a pre-defined daily regular load
ResourceCalendar(double timeZone, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekendList, LinkedList holidayList, long seed)
          Allocates a new ResourceCalendar object with a default daily regular load.
 
Method Summary
 Calendar getCalendarAtGivenDate(Date date)
          Gets a Calendar object at the specified date
 Calendar getCalendarAtSimulationTime(double simulationTime)
          Gets a Calendar object for a specified simulation time
 Calendar getCurrentCalendar()
          Gets the current Calendar object (based on the simulation clock)
 double getCurrentLoad()
          Gets the current load for the current simulation time
 double getSimulationTime(Calendar localTime)
          Gets the current simulation time
 boolean isHoliday()
          Checks whether the current simulation time is a holiday or not
 boolean isHoliday(Date date)
          Checks whether the given date is a holiday or not
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceCalendar

public ResourceCalendar(double timeZone,
                        double peakLoad,
                        double offPeakLoad,
                        double relativeHolidayLoad,
                        LinkedList weekendList,
                        LinkedList holidayList,
                        long seed)
Allocates a new ResourceCalendar object with a default daily regular load.

Parameters:
timeZone - time zone
peakLoad - the load during peak time, with range: [0 ... 1]
offPeakLoad - the load during off peak time, with range: [0 ... 1]
relativeHolidayLoad - the load during holidays, with range: [0 ... 1]
weekendList - a list of Integer numbers for weekends
holidayList - a list of Integer numbers for holidays
seed - the initial seed
Pre Condition:
timeZone >= 0.0, seed > 0
Post Condition:
$none

ResourceCalendar

public ResourceCalendar(double[] regularLoad,
                        double timeZone,
                        double peakLoad,
                        double offPeakLoad,
                        double relativeHolidayLoad,
                        LinkedList weekendList,
                        LinkedList holidayList,
                        long seed)
Allocates a new ResourceCalendar object with a pre-defined daily regular load

Parameters:
regularLoad - the daily regular load, with range: [0 ... 1]. Note that regularLoad[0] represents time 00:00 (hh:mm), and regularLoad[23] represents time 23:00.
timeZone - time zone
peakLoad - the load during peak time, with range: [0 ... 1]
offPeakLoad - the load during off peak time, with range: [0 ... 1]
relativeHolidayLoad - the load during holidays, with range: [0 ... 1]
weekendList - a list of Integer numbers for weekends
holidayList - a list of Integer numbers for holidays
seed - the initial seed
Pre Condition:
timeZone >= 0.0, seed > 0
Post Condition:
$none
Method Detail

getCalendarAtSimulationTime

public Calendar getCalendarAtSimulationTime(double simulationTime)
                                     throws NullPointerException
Gets a Calendar object for a specified simulation time

Parameters:
simulationTime - the simulation time
Returns:
a Calendar object
Throws:
NullPointerException - if GridSim.init() has not been called before
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
simulationTime >= 0.0
Post Condition:
$result != null

getCurrentCalendar

public Calendar getCurrentCalendar()
                            throws NullPointerException
Gets the current Calendar object (based on the simulation clock)

Returns:
the current Calendar object
Throws:
NullPointerException - if GridSim.init() has not been called before
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String), Sim_system.clock()
Pre Condition:
$none
Post Condition:
$result != null

getSimulationTime

public double getSimulationTime(Calendar localTime)
                         throws NullPointerException
Gets the current simulation time

Parameters:
localTime - a Calendar object
Returns:
the current simulation time
Throws:
NullPointerException - if localTime is null or GridSim.init() has not been called before
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
localTime != null
Post Condition:
$result >= 0.0

getCalendarAtGivenDate

public Calendar getCalendarAtGivenDate(Date date)
Gets a Calendar object at the specified date

Parameters:
date - the Date object
Returns:
the Calendar object
Pre Condition:
date != null
Post Condition:
$result != null

isHoliday

public boolean isHoliday()
                  throws NullPointerException
Checks whether the current simulation time is a holiday or not

Returns:
true if it is a holiday, otherwise returns false
Throws:
NullPointerException - if GridSim.init() has not been called before
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
$none
Post Condition:
$result == true || $result == false

isHoliday

public boolean isHoliday(Date date)
Checks whether the given date is a holiday or not

Parameters:
date - the Date object
Returns:
true if it is a holiday, otherwise returns false
Pre Condition:
date != null
Post Condition:
$result == true || $result == false

getCurrentLoad

public double getCurrentLoad()
                      throws NullPointerException
Gets the current load for the current simulation time

Returns:
the current load
Throws:
NullPointerException - if GridSim.init() has not been called before
See Also:
GridSim.init(int, Calendar, boolean, String[], String[], String)
Pre Condition:
$none
Post Condition:
$result >= 0.0

GridSim 5.0 beta

The University of Melbourne, Australia, 2009