雲端運算模擬工具中文注釋VmScheduler.java

來源:互聯網
上載者:User
/* * 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 java.util.HashMap;import java.util.List;import java.util.Map;import org.cloudbus.cloudsim.lists.PeList;/** * vm的調度策略(空間和時間) * VmScheduler is an abstract class that represents the * policy used by a VMM to share processing power among VMs running * in a host. * * @authorRodrigo N. Calheiros * @authorAnton Beloglazov * @sinceCloudSim Toolkit 1.0 */public abstract class VmScheduler {/** The peList.每個host有個pe列表*/private List<? extends Pe> peList;/** The MIPS that are currently allocated to the VMs.  * 記錄每個vm分配得到的mips * */private Map<String, List<Double>> mipsMap;/** The total available mips. */private double availableMips;/** * Creates a new HostAllocationPolicy. * * @param pelist the pelist * * @pre peList != $null * @post $none */public VmScheduler(List<? extends Pe> pelist) {setPeList(pelist);setMipsMap(new HashMap<String, List<Double>>());setAvailableMips(PeList.getTotalMips(getPeList()));}/** * Allocates PEs for a VM. * * @param vm the vm * @param mipsShare the mips share * * @return $true if this policy allows a new VM in the host, $false otherwise * * @pre $none * @post $none */public abstract boolean allocatePesForVm(Vm vm, List<Double> mipsShare);/** * Releases PEs allocated to a VM. * * @param vm the vm * * @pre $none * @post $none */public abstract void deallocatePesForVm(Vm vm);/** * 回收所有vms的mips。 * 1、對主機中所有pe操作 * 2、每個pe中所有vm操作 * Releases PEs allocated to all the VMs. * * @param vm the vm * * @pre $none * @post $none */public void deallocatePesForAllVms() {getMipsMap().clear();setAvailableMips(PeList.getTotalMips(getPeList()));   //一台主機所有的mipsfor (Pe pe : getPeList()) {pe.getPeProvisioner().deallocateMipsForAllVms();   //每個pe回收所有mips}}/** * Returns the MIPS share of each Pe that is allocated to a given VM. * 返回特定vm使用的mips列表 * @param vm the vm * * @return an array containing the amount of MIPS of each pe that is available to the VM * * @pre $none * @post $none */public List<Double> getAllocatedMipsForVm(Vm vm) {return getMipsMap().get(vm.getUid());}/** * Gets the total allocated MIPS for a VM over all the PEs. * 一個vm總共佔用的mips * @param vm the vm * * @return the allocated mips for vm */public double getTotalAllocatedMipsForVm(Vm vm) {double allocated = 0;List<Double> mipsMap = getAllocatedMipsForVm(vm);if (mipsMap != null) {for (double mips : mipsMap) {allocated += mips;}}return allocated;}/** * Returns maximum available MIPS among all the PEs. * 返回所有pe中最大可用MIPS * @return max mips */public double getMaxAvailableMips() {if (getPeList() == null) {Log.printLine("Pe list is empty");return 0;}double max = 0.0;for (Pe pe : getPeList()) {double tmp = pe.getPeProvisioner().getAvailableMips();if (tmp > max) {max = tmp;}}return max;}/** * Returns PE capacity in MIPS. * 第一個pe的mips * @return mips */public double getPeCapacity() {if (getPeList() == null) {Log.printLine("Pe list is empty");return 0;}return getPeList().get(0).getMips();}/** * Gets the vm list. * vm調度,其實就是host中的pe分配策略 * 返回了pe列表 * @return the vm list */@SuppressWarnings("unchecked")public <T extends Pe> List<T> getPeList() {return (List<T>) peList;}/** * Sets the vm list. * * @param peList the pe list */protected <T extends Pe> void setPeList(List<T> peList) {this.peList = peList;}/** * Gets the mips map. * 獲得所佔用pe的列表,pelist * @return the mips map */protected Map<String, List<Double>> getMipsMap() {return mipsMap;}/** * Sets the mips map. * * @param mipsMap the mips map */protected void setMipsMap(Map<String, List<Double>> mipsMap) {this.mipsMap = mipsMap;}/** * Gets the free mips. * * @return the free mips */public double getAvailableMips() {return availableMips;}/** * Sets the free mips. * * @param availableMips the new free mips */protected void setAvailableMips(double availableMips) {this.availableMips = availableMips;}}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.