云计算仿真工具中文注释Pe.java

/*
 * Title:        CloudSim Toolkit
 * Description:  CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 *
 * Copyright (c) 2009-2010, The University of Melbourne, Australia
 */

package org.cloudbus.cloudsim;

import org.cloudbus.cloudsim.provisioners.PeProvisioner;

/**
 * Pe代表cpu单元,字段:pe状态和分配策略peProvisioner
 * 同一台主机所有pe有相同的处理能力
 * CloudSim Pe (Processing Element) class represents CPU unit,
 * defined in terms of Millions Instructions Per Second (MIPS) rating.<br>
 * <b>ASSUMPTION:<b> All PEs under the same Machine have the same MIPS rating.
 *
 * @author      Manzur Murshed
 * @author		Rajkumar Buyya
 * @since		CloudSim Toolkit 1.0
 */
public class Pe {

    /** Denotes Pe is FREE for allocation. */
    public static final int FREE  = 1;

    /** Denotes Pe is allocated and hence busy in processing Cloudlet. */
    public static final int BUSY = 2;

    /** Denotes Pe is failed and hence it can't process any Cloudlet at this moment. This Pe is failed because it belongs to a machine which is also failed. */
    public static final int FAILED = 3;

    /** The id. */
    private int id;

    // FOR SPACE SHARED RESOURCE: Jan 21
    /** The status of Pe: FREE, BUSY, FAILED: . */
    private int status;

	/** The pe provisioner.pe分配策略 */
	private PeProvisioner peProvisioner;

    /**
     * Allocates a new Pe object.
     *
     * @param id    the Pe ID
     * @param peProvisioner the pe provisioner
     *
     * @pre id >= 0
     * @pre peProvisioner != null
     * @post $none
     */
    public Pe(int id, PeProvisioner peProvisioner) {
        setId(id);
        setPeProvisioner(peProvisioner);

        // when created it should be set to FREE, i.e. available for use.
        this.status = FREE;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	protected void setId(int id) {
		this.id = id;
	}

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public int getId() {
		return id;
	}

    /**
     * Sets the MIPS Rating of this Pe.
     *
     * @param d the mips
     *
     * @pre mips >= 0
     * @post $none
     */
    public void setMips(double d) {
        getPeProvisioner().setMips(d);
    }

    /**
     * Gets the MIPS Rating of this Pe.
     *
     * @return the MIPS Rating
     *
     * @pre $none
     * @post $result >= 0
     */
    public int getMips() {
        return (int) getPeProvisioner().getMips();
    }

    /**
     * Gets the status of this Pe.
     *
     * @return the status of this Pe
     *
     * @pre $none
     * @post $none
     */
    public int getStatus() {
        return status;
    }

    /**
     * Sets Pe status to free, meaning it is available for processing.
     * This should be used by SPACE shared hostList only.
     *
     * @pre $none
     * @post $none
     */
    public void setStatusFree() {
        setStatus(FREE);
    }

    /**
     * Sets Pe status to busy, meaning it is already executing Cloudlets.
     * This should be used by SPACE shared hostList only.
     *
     * @pre $none
     * @post $none
     */
    public void setStatusBusy() {
    	setStatus(BUSY);
    }

    /**
     * Sets this Pe to FAILED.
     *
     * @pre $none
     * @post $none
     */
    public void setStatusFailed() {
    	setStatus(FAILED);
    }

    /**
     * Sets Pe status to either <tt>Pe.FREE</tt> or <tt>Pe.BUSY</tt>
     *
     * @param status     Pe status, <tt>true</tt> if it is FREE, <tt>false</tt>
     * if BUSY.
     *
     * @pre $none
     * @post $none
     */
    public void setStatus(int status) {
        this.status = status;
    }

	/**
	 * Sets the pe provisioner.
	 *
	 * @param peProvisioner the new pe provisioner
	 */
	protected void setPeProvisioner(PeProvisioner peProvisioner) {
		this.peProvisioner = peProvisioner;
	}

	/**
	 * Gets the Pe provisioner.
	 *
	 * @return the Pe provisioner
	 */
	public PeProvisioner getPeProvisioner() {
		return this.peProvisioner;
	}

}


 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值