📄 gridresourcewithfailure.java
字号:
/* * Title: GridSim Toolkit * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * * Author: Agustin Caminero and Anthony Sulistio * Organization: Universidad de Castilla La Mancha (UCLM), Spain. * Created on: Nov 2006. */package gridsim.resFailure;import gridsim.resFailure.*;import gridsim.*;import gridsim.net.*;import gridsim.index.*;import java.util.LinkedList;import eduni.simjava.Sim_event;import eduni.simjava.Sim_system;import gridsim.resFailure.FailureMsg;import java.io.FileWriter;/** * GridResourceWithFailure is based on {@link gridsim.GridResource}, but with * added failure functionalities. * GridResourceWithFailure extends the {@link gridsim.GridSimCore} class for * gaining communication and concurrent entity capabilities. * An instance of this class stimulates a resource * with properties defined in an object of * {@link gridsim.ResourceCharacteristics} class. * * @author Agustin Caminero and Anthony Sulistio * @since GridSim Toolkit 4.1 * @see gridsim.GridResource * @see gridsim.ResourceCharacteristics * @see gridsim.resFailure.AllocPolicyWithFailure * @invariant $none */public class GridResourceWithFailure extends GridSimCore{ /** Characteristics of this resource */ protected ResourceCharacteristics resource_; /** a ResourceCalendar object */ protected ResourceCalendar resCalendar_; /** A resource's scheduler. This object is reponsible in scheduling and * and executing submitted Gridlets. */ protected AllocPolicy policy_; /** A scheduler type of this resource, such as FCFS, Round Robin, etc */ protected int policyType_; /** Integer object size, including its overhead */ protected final int SIZE = 12; /** Regional GIS entity name */ protected String regionalGISName_; // a flag to denote whether to record events into a file or not private boolean record_ = false; /** * Allocates a new GridResourceWithFailure object. When making a different * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, double, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) * @param baud_rate network communication or bandwidth speed * @param seed the initial seed * @param resource an object of ResourceCharacteristics * @param peakLoad the load during peak times * @param offPeakLoad the load during off peak times * @param relativeHolidayLoad the load during holiday times * @param weekends a linked-list contains the weekend days * @param holidays a linked-list contains the public holidays * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> creating this entity before initializing GridSim package * <li> this entity name is <tt>null</tt> or empty * <li> this entity has <tt>zero</tt> number of PEs (Processing * Elements). <br> * 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. * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @see gridsim.GridSim#init(int, Calendar, boolean) * @see #GridResourceWithFailure(String, double, * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) * @pre name != null * @pre baud_rate > 0 * @pre resource != null * @post $none */ public GridResourceWithFailure(String name, double baud_rate, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays) throws Exception { super(name, baud_rate); resource_ = resource; resCalendar_ = new ResourceCalendar(resource_.getResourceTimeZone(), peakLoad, offPeakLoad, relativeHolidayLoad, weekends, holidays, seed); policy_ = null; init(); } /** * Allocates a new GridResourceWithFailure object. When making a different * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, double, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) * @param baud_rate network communication or bandwidth speed * @param resource an object of ResourceCharacteristics * @param calendar an object of ResourceCalendar * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> creating this entity before initializing GridSim package * <li> this entity name is <tt>null</tt> or empty * <li> this entity has <tt>zero</tt> number of PEs (Processing * Elements). <br> * 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. * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @see gridsim.GridSim#init(int, Calendar, boolean) * @see #GridResourceWithFailure(String, double, * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) * @pre name != null * @pre baud_rate > 0 * @pre resource != null * @pre calendar != null * @post $none */ public GridResourceWithFailure(String name, double baud_rate, ResourceCharacteristics resource, ResourceCalendar calendar) throws Exception { super(name, baud_rate); resource_ = resource; resCalendar_ = calendar; policy_ = null; init(); } /** * Allocates a new GridResourceWithFailure object. When making a different * type of GridResourceWithFailure object, use this constructor and then * overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) * @param baud_rate network communication or bandwidth speed * @param resource an object of ResourceCharacteristics * @param calendar an object of ResourceCalendar * @param policy a scheduling policy for this Grid resource. If no * scheduling policy is defined, the default one is * <tt>SpaceShared</tt> * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> creating this entity before initializing GridSim package * <li> this entity name is <tt>null</tt> or empty * <li> this entity has <tt>zero</tt> number of PEs (Processing * Elements). <br> * 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. * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @see gridsim.GridSim#init(int, Calendar, boolean) * @see gridsim.resFailure.AllocPolicyWithFailure * @pre name != null * @pre baud_rate > 0 * @pre resource != null * @pre calendar != null * @pre policy != null * @post $none */ public GridResourceWithFailure(String name, double baud_rate, ResourceCharacteristics resource, ResourceCalendar calendar, AllocPolicyWithFailure policy) throws Exception { super(name, baud_rate); resource_ = resource; resCalendar_ = calendar; // the order between policy and init() is important policy_ = (AllocPolicy) policy; init(); } //////////////////////////////////////////// /** * Allocates a new GridResourceWithFailure object. When making a different * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, Link, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) * @param link the link that will be used to connect this * GridResourceWithFailure to another Entity or Router. * @param seed the initial seed * @param resource an object of ResourceCharacteristics * @param peakLoad the load during peak times * @param offPeakLoad the load during off peak times * @param relativeHolidayLoad the load during holiday times * @param weekends a linked-list contains the weekend days * @param holidays a linked-list contains the public holidays * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> creating this entity before initializing GridSim package * <li> this entity name is <tt>null</tt> or empty * <li> this entity has <tt>zero</tt> number of PEs (Processing * Elements). <br> * 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. * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @pre name != null * @pre link != null * @pre resource != null * @post $none */ public GridResourceWithFailure(String name, Link link, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays) throws Exception { super(name, link); resource_ = resource; resCalendar_ = new ResourceCalendar(resource_.getResourceTimeZone(), peakLoad, offPeakLoad, relativeHolidayLoad, weekends, holidays, seed); policy_ = null; init(); } /** * Allocates a new GridResourceWithFailure object. When making a different * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, Link, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) * @param link the link that will be used to connect this * GridResourceWithFailure to another Entity or Router. * @param resource an object of ResourceCharacteristics * @param calendar an object of ResourceCalendar * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> creating this entity before initializing GridSim package * <li> this entity name is <tt>null</tt> or empty * <li> this entity has <tt>zero</tt> number of PEs (Processing * Elements). <br> * 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. * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @pre name != null * @pre link != null * @pre resource != null * @pre calendar != null * @post $none */ public GridResourceWithFailure(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar) throws Exception { super(name, link); resource_ = resource; resCalendar_ = calendar; policy_ = null; init(); } /** * Allocates a new GridResourceWithFailure object. When making a different * type of GridResourceWithFailure object, use this constructor and then * overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) * @param link the link that will be used to connect this * GridResourceWithFailure to another Entity or Router. * @param resource an object of ResourceCharacteristics * @param calendar an object of ResourceCalendar * @param policy a scheduling policy for this Grid resource. If no * scheduling policy is defined, the default one is * <tt>SpaceShared</tt> * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> creating this entity before initializing GridSim package * <li> this entity name is <tt>null</tt> or empty * <li> this entity has <tt>zero</tt> number of PEs (Processing * Elements). <br> * 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. * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @see gridsim.resFailure.AllocPolicyWithFailure * @pre name != null * @pre link != null * @pre resource != null * @pre calendar != null * @pre policy != null * @post $none */ public GridResourceWithFailure(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar, AllocPolicyWithFailure policy) throws Exception { super(name,link);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -