⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brokerresource.java

📁 实现网格环境下资源调度和分配的仿真
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public double getFirstAvailableSlotTime()    {        int numPE = resource.getNumPE();        int pe_slots_committed = 0;        if (numPE > 0) {            pe_slots_committed = getNumGridletCommitted() / numPE;        }        Accumulator gl_acc = getUnFinishedGridletLengthAccumulator();        double time_to_process_per_gridlet = 0.0;        if (gl_acc.getCount() != 0)        {            double available = getAvailableMIPSPerPE();            if (available > 0.0) {                time_to_process_per_gridlet = gl_acc.getMean() / available;            }        }        double first_available_slot = pe_slots_committed *                                      time_to_process_per_gridlet;        return first_available_slot;    }    /**     * Gets the expected Grid completion time given its current commitmements     * @param gl    a Gridlet object     * @return the expected completion time     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getExpectedCompletionTime(Gridlet)}     * @pre gl != null     * @post $result >= 0     */    public double ExpectedCompletionTime(Gridlet gl) {        return this.getExpectedCompletionTime(gl);    }    /**     * Gets the expected Grid completion time given its current commitmements     * @param gl    a Gridlet object     * @return the expected completion time     * @pre gl != null     * @post $result >= 0     */    public double getExpectedCompletionTime(Gridlet gl)    {        double available = getAvailableMIPSPerPE();        double time = 0.0;        if (available > 0.0) {            time = getFirstAvailableSlotTime() + gl.getGridletLength() /                   available;        }        return time;    }    /**     * Gets an Accumulator object for the length of all gridlets to be     * completely processed.     * It is also include all gridlets for a Broker Resource that either in     * READY, QUEUED, or in INEXEC state.     * @return an Accumulator object     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getUnFinishedGridletLengthAccumulator()}     * @see gridsim.Accumulator     * @pre $none     * @post $result != null     */    public Accumulator GetUnFinishedGridletsLengthAccumulator() {        return this.getUnFinishedGridletLengthAccumulator();    }    /**     * Gets an Accumulator object for the length of all gridlets to be     * completely processed.     * It is also include all gridlets for a Broker Resource that either in     * READY, QUEUED, or in INEXEC state.     * @return an Accumulator object     * @see gridsim.Accumulator     * @pre $none     * @post $result != null     */    public Accumulator getUnFinishedGridletLengthAccumulator()    {        Accumulator accLength = new Accumulator();        for (int i = 0; i < glList.size(); i++)        {            int status = ( (Gridlet) glList.get(i) ).getGridletStatus();            if ( status == Gridlet.READY || status == Gridlet.QUEUED ||                 status == Gridlet.INEXEC )            {                accLength.add( ((Gridlet) glList.get(i)).getGridletLength() );            }        }        return accLength;    }    /**     * Gets the number of System Time units (such as second) from the     * current time to the endTime (such as Deadline)     * @param endTime   the ending time     * @return the remainding time period     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getRemainingTimePeriod(double)}     * @pre endTime >= 0.0     * @post $result >= 0     */    public double RemainingTimePeriodFromNow(double endTime) {        return this.getRemainingTimePeriod(endTime);    }    /**     * Gets the number of System Time units (such as second) from the     * current time to the endTime (such as Deadline)     * @param endTime   the ending time     * @return the remainding time period     * @pre endTime >= 0.0     * @post $result >= 0     */    public double getRemainingTimePeriod(double endTime) {        return endTime - GridSim.clock();    }    /**     * Checks the available MI (Millions Instruction) on a single PE (Processing     * Element) within the available deadline period     * @param gl    a Gridlet object     * @param deadlineTime  the deadline time period     * @return <tt>true</tt> if it is sufficient for a Gridlet to run     *         successfully, otherwise <tt>false</tt>     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #isSufficientMIAvailableOnSinglePE(Gridlet, double)}     * @see gridsim.Gridlet     * @pre $none     * @post $none     */    public boolean IsSufficientMIAvailableOnSinglePE(Gridlet gl,                        double deadlineTime)    {        return this.isSufficientMIAvailableOnSinglePE(gl, deadlineTime);    }    /**     * Checks the available MI (Millions Instruction) on a single PE (Processing     * Element) within the available deadline period     * @param gl    a Gridlet object     * @param deadlineTime  the deadline time period     * @return <tt>true</tt> if it is sufficient for a Gridlet to run     *         successfully, otherwise <tt>false</tt>     * @see gridsim.Gridlet     * @pre $none     * @post $none     */    public boolean isSufficientMIAvailableOnSinglePE(Gridlet gl,                        double deadlineTime)    {        double GridletNeedMI = gl.getGridletLength();        double TimeSpan = getRemainingTimePeriod(deadlineTime);        double AvailableMIonOnePE = getAvailableMIPSPerPE() * TimeSpan;        if (AvailableMIonOnePE >= GridletNeedMI) {            return true;        }        else {            return false;        }    }    /**     * Gets the available MIs depending on resource load from the end time     * @param endTime   the end time     * @return the available MIs     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getAvailableMI(double)}     * @pre endTime >= 0.0     * @post $result >= 0.0     */    public double GetAvailableMI(double endTime) {        return this.getAvailableMI(endTime);    }    /**     * Gets the available MIs depending on resource load from the end time     * @param endTime   the end time     * @return the available MIs     * @pre endTime >= 0.0     * @post $result >= 0.0     */    public double getAvailableMI(double endTime)    {        double TimeSpan = getRemainingTimePeriod(endTime);        double AvailableMI = availableMIPS_ * TimeSpan;        // deduct MIs that are already committed (Queued/InExec) due to        // assignment of Gridlet to a resource        Gridlet gl = null;        for (int i = 0; i < glList.size(); i++)        {            gl = (Gridlet) glList.get(i);            if (gl.getGridletStatus() != Gridlet.READY) {                AvailableMI -= gl.getGridletLength();            }        }        return AvailableMI;    }    /**     * Gets the number of Gridlets committed     * @return the number of Gridlets committed     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getNumGridletCommitted()}     * @pre $none     * @post $result >= 0     */    public int NoOfGridletsCommitted() {        return this.getNumGridletCommitted();    }    /**     * Gets the number of Gridlets committed     * @return the number of Gridlets committed     * @pre $none     * @post $result >= 0     */    public int getNumGridletCommitted()    {        int num = getNumGridletInReady() + getNumGridletInQueue() +                  getNumGridletInExec();        return num;    }    /**     * Gets the number of Gridlets in ready     * @return the number of Gridlets in ready     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getNumGridletInReady()}     * @pre $none     * @post $result >= 0     */    public int NoOfGridletsInReady() {        return this.getNumGridletInReady();    }    /**     * Gets the number of Gridlets in ready     * @return the number of Gridlets in ready     * @pre $none     * @post $result >= 0     */    public int getNumGridletInReady() {        return this.getNumGridlet(Gridlet.READY);    }    /**     * Gets the number of Gridlets in queue     * @return the number of Gridlets in queue     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getNumGridletInQueue()}     * @pre $none     * @post $result >= 0     */    public int NoOfGridletsInQueue() {        return this.getNumGridletInQueue();    }    /**     * Gets the number of Gridlets in queue     * @return the number of Gridlets in queue     * @pre $none     * @post $result >= 0     */    public int getNumGridletInQueue() {        return this.getNumGridlet(Gridlet.QUEUED);    }    /**     * Gets the number of Gridlets in execution     * @return the number of Gridlets in execution     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getNumGridletInExec()}     * @pre $none     * @post $result >= 0     */    public int NoOfGridletsInExec() {        return this.getNumGridletInExec();    }    /**     * Gets the number of Gridlets in execution     * @return the number of Gridlets in execution     * @pre $none     * @post $result >= 0     */    public int getNumGridletInExec() {        return this.getNumGridlet(Gridlet.INEXEC);    }    /**     * Identifies an expected processing cost on the resource     * @param gl    a Gridlet object     * @return the expected processing cost or <tt>0</tt> if a Grid resource     *         or Gridlet is empty     * @see gridsim.Gridlet     * @deprecated As of GridBroker 2.1, replaced by     *             {@link #getExpectedProcessingCost(Gridlet)}     * @pre gl != null     * @post $result >= 0.0     */    public double ExpectedProcessingCost(Gridlet gl) {        return this.getExpectedProcessingCost(gl);    }    /**     * Identifies an expected processing cost on the resource     * @param gl    a Gridlet object     * @return the expected processing cost or <tt>0</tt> if a Grid resource     *         or Gridlet is empty     * @see gridsim.Gridlet     * @pre gl != null     * @post $result >= 0.0     */    public double getExpectedProcessingCost(Gridlet gl)    {        double result = gl.getGridletLength() * resource.getCostPerMI();        if (result < 0.0) {            result = 0.0;        }        return result;    }    ///////////////////////// PRIVATE METHODS /////////////////////////    /**     * Gets the number of Gridlets based on a specified Gridlet status     * @param gridletStatus     the Gridlet status     * @return the number of Gridlets     * @pre gridletStatus >= 0     * @post $result >= 0     */    private int getNumGridlet(int gridletStatus)    {        int count = 0;        Gridlet gl = null;        for (int i = 0; i < glList.size(); i++)        {            gl = (Gridlet) glList.get(i);            if (gl.getGridletStatus() == gridletStatus) {                count++;            }        }        return count;    }} // end class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -