📄 brokerresource.java
字号:
/* * Title: Grid Broker * Description: A Grid Scheduler for Application Scheduling on Grid based on * Deadline and Budget Constrained Scheduling Algorithms * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * $Id: BrokerResource.java,v 1.6 2003/06/30 05:10:55 anthony Exp $ */package gridbroker;import gridsim.*;import eduni.simjava.Sim_event;/** * BrokerResource class acts as a placeholder for the broker to maintain a * detailed record on the resources it uses for processing user applications. It * maintains resource characteristics, a list of Gridlets assigned to the * resource, the actual amount of MIPS (Millions Instruction Per Second) * available to the user, and a report on the Gridlets processed. These * measurements help in extrapolating and predicating the resource performance * from the user point of view and aid in scheduling job dynamically at * runtime. * * @author Manzur Murshed and Rajkumar Buyya * @version 2.1, June 2003 * @invariant $none */public class BrokerResource{ /** A ResourceCharacteristics object */ public ResourceCharacteristics resource; /** Denotes the latest load */ public double LatestLoad; /** List of Gridlets that are currently assigned to a resource */ public GridletList glList; /** Number of Gridlets that are finished so far */ public int NoOfGridletsFinishedSoFar; /** Number of Gridlets that are dispatched so far */ public int NoOfGridletsDispatchedSoFar; /** Processing expenses so far */ public double ProcessingExpensesSoFar; /** Gridlets on a resource */ public static final int PARAM_GRIDLETS_ON_RESOURCE = 1; /** Gridlets that are committed */ public static final int PARAM_GRIDLETS_COMMITTED_FOR_RESOURCE = 2; /** Gridlets that are finished */ public static final int PARAM_GRIDLETS_FINISHED = 3; /** Processing expenses */ public static final int PARAM_PROCESSING_EXPENSES = 4; // Total MIPS actually available to the user on a resource private double availableMIPS_; // THIS IS USED IN SCHEDULING DECISION PURPOSE. private double availableMIPS_PrevSchedule_; /** * Allocates a new BrokerResource object * @param resObj an object of ResourceCharacteristics * @param latestLoad the latest resource load * @see gridsim.ResourceCharacteristics * @pre resObj != null * @pre latestLoad >= 0.0 * @post $none */ public BrokerResource(ResourceCharacteristics resObj, double latestLoad) { this.resource = resObj; this.LatestLoad = latestLoad; glList = new GridletList(); try { availableMIPS_ = resource.getMIPSRating(); } catch (Exception e) { availableMIPS_ = 0.0; } // FIRST time both last and current will be same. availableMIPS_PrevSchedule_ = availableMIPS_; NoOfGridletsFinishedSoFar = 0; NoOfGridletsDispatchedSoFar = 0; ProcessingExpensesSoFar = 0; } /** * Gets the parameter value * @param parameter the type of a parameter * @return the parameter value * @deprecated As of GridBroker 2.1, replaced by * {@link #getParameterValue(int)} * @pre parameter >= 1 && parameter <= 4 * @post $result >= 0.0 */ public double GetParameterValue(int parameter) { return this.getParameterValue(parameter); } /** * Gets the parameter value * @param parameter the type of a parameter * @return the parameter value * @pre parameter >= 1 && parameter <= 4 * @post $result >= 0.0 */ public double getParameterValue(int parameter) { double value = -1; // undefined switch (parameter) { case PARAM_GRIDLETS_ON_RESOURCE: value = getNumGridletInQueue() + getNumGridletInExec(); break; case PARAM_GRIDLETS_COMMITTED_FOR_RESOURCE: value = getNumGridletCommitted(); break; case PARAM_GRIDLETS_FINISHED: value = NoOfGridletsFinishedSoFar; break; case PARAM_PROCESSING_EXPENSES: value = ProcessingExpensesSoFar; break; default: break; } return value; } /** * Gets the available MIPS * @return the available MIPS * @deprecated As of GridBroker 2.1, replaced by {@link #getAvailableMIPS()} * @pre $none * @post $result >= 0 */ public double GetAvailableMIPS() { return this.getAvailableMIPS(); } /** * Gets the available MIPS * @return the available MIPS * @pre $none * @post $result >= 0 */ public double getAvailableMIPS() { return availableMIPS_; } /** * Gets the available MIPS based on previous schedule * @return the available MIPS * @deprecated As of GridBroker 2.1, replaced by * {@link #getAvailableMIPS_PreviousSchedule()} * @pre $none * @post $result >= 0 */ public double GetAvailableMIPS_PreviousSchedule() { return this.getAvailableMIPS_PreviousSchedule(); } /** * Gets the available MIPS based on previous schedule * @return the available MIPS * @pre $none * @post $result >= 0 */ public double getAvailableMIPS_PreviousSchedule() { return availableMIPS_PrevSchedule_; } /** * Sets the available MIPS based on previous schedule * @deprecated As of GridBroker 2.1, replaced by * {@link #setAvailableMIPS_PreviousSchedule()} * @pre $none * @post $none */ public void SetAvailableMIPS_PreviousSchedule() { this.setAvailableMIPS_PreviousSchedule(); } /** * Sets the available MIPS based on previous schedule * @pre $none * @post $none */ public void setAvailableMIPS_PreviousSchedule() { availableMIPS_PrevSchedule_ = availableMIPS_; } /** * Gets the resource share since the last schedule. * If the value is greater than 1, then higher share is available. * @return the resource share * @deprecated As of GridBroker 2.1, replaced by * {@link #getResourceShareVariation()} * @pre $none * @post $result >= 0 */ public double ResourceShareVariation() { return this.getResourceShareVariation(); } /** * Gets the resource share since the last schedule. * If the value is greater than 1, then higher share is available. * @return the resource share or <tt>0</tt> if not available * @pre $none * @post $none */ public double getResourceShareVariation() { // variation from previous schedule double variation = 0.0; if (availableMIPS_PrevSchedule_ != 0.0) { variation = availableMIPS_ / availableMIPS_PrevSchedule_; } return variation; } /** * Updates the total available MIPS * @param glFinished a Gridlet object that has finished * @param brokerMaxGridletPerPELimit the max. number of Gridlet per PE * (Processing Element) * @see gridsim.Gridlet * @deprecated As of GridBroker 2.1, replaced by * {@link #updateAvailableMIPS(Gridlet, int)} * @pre glFinished != null * @pre brokerMaxGridletPerPELimit >= 0 * @post $none */ public void UpdateAvailableMIPS(Gridlet glFinished, int brokerMaxGridletPerPELimit) { this.updateAvailableMIPS(glFinished, brokerMaxGridletPerPELimit); } /** * Updates the total available MIPS * @param glFinished a Gridlet object that has finished * @param brokerMaxGridletPerPELimit the max. number of Gridlet per PE * (Processing Element) * @see gridsim.Gridlet * @pre glFinished != null * @pre brokerMaxGridletPerPELimit >= 0 * @post $none */ public void updateAvailableMIPS(Gridlet glFinished, int brokerMaxGridletPerPELimit) { double clockTime = glFinished.getWallClockTime(); double MIPSPerGridlet = 0.0; if (clockTime != 0.0) { MIPSPerGridlet = glFinished.getGridletLength() / clockTime; } int numPE = resource.getNumPE(); double MaxGridletsPerPE = 0.0; if (numPE > 0) { MaxGridletsPerPE = Math.max(1.0, (getNumGridletInExec()+1) / numPE); } // make sure that MaxGridletsPerPE is NOT more than broker // actually assigned MaxGridletsPerPE = Math.min(MaxGridletsPerPE, brokerMaxGridletPerPELimit); availableMIPS_ = MIPSPerGridlet * MaxGridletsPerPE * numPE; } /** * Updates the available MIPS during simulation schedule * @deprecated As of GridBroker 2.1, replaced by * {@link #updateAvailableMIPSDuringSchedule()} * @pre $none * @post $none */ public void UpdateAvailableMIPSDuringSchedule() { this.updateAvailableMIPSDuringSchedule(); } /** * Updates the available MIPS during simulation schedule * @pre $none * @post $none */ public void updateAvailableMIPSDuringSchedule() { // save AvailableMIPS in the last schedule availableMIPS_PrevSchedule_ = availableMIPS_; } /** * Identifies the actual MIPS available per PE (Processing Element) * @return the actual MPIS available for the current user * @deprecated As of GridBroker 2.1, replaced by * {@link #getAvailableMIPSPerPE()} * @pre $none * @post $result >= 0 */ public double GetAvailableMIPSPerPE() { return this.getAvailableMIPSPerPE(); } /** * Identifies the actual MIPS available per PE (Processing Element) * @return the actual MPIS available for the current user * @pre $none * @post $result >= 0 */ public double getAvailableMIPSPerPE() { double available = 0.0; int numPE = resource.getNumPE(); if (numPE > 0) { available = availableMIPS_ / numPE; } return available; } /** * Gets the time at which the first slot is available, considering the * current committed Gridlets * @return the available time * @deprecated As of GridBroker 2.1, replaced by * {@link #getFirstAvailableSlotTime()} * @pre $none * @post $result >= 0 */ public double FirstAvailableSlotTime() { return this.getFirstAvailableSlotTime(); } /** * Gets the time at which the first slot is available, considering the * current committed Gridlets * @return the available time * @pre $none * @post $result >= 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -