CloudSim源代码学习之Vm.doc_第1页
CloudSim源代码学习之Vm.doc_第2页
CloudSim源代码学习之Vm.doc_第3页
CloudSim源代码学习之Vm.doc_第4页
CloudSim源代码学习之Vm.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

package org.cloudbus.cloudsim;import java.util.ArrayList;/This class provides methods to manipulate the size of the array that is used internally to store the list.import java.util.List;/*【虚拟机】 * Vm represents a VM: 【it runs inside a Host, sharing hostList * with other VMs. It processes cloudlets. 】This processing happens according * to a policy, defined by the CloudletScheduler. Each VM has a owner(每个虚拟机有一个所有者), which can * submit cloudlets to the VM to be executed * * authorRodrigo N. Calheiros * authorAnton Beloglazov * sinceCloudSim Toolkit 1.0 */public class Vm /* The id. ID号*/private int id;/* The user id. 用户编号*/private int userId;private String uid;/* The size. 大小 */private long size;/* The MIPS.处理速度MIPS */private double mips;/* The PEs number. PE数*/private int pesNumber;/* The ram. 内存*/private int ram;/* The bw.带宽 */private long bw;/* The vmm. 虚拟机管理程序*/private String vmm;/* The Cloudlet scheduler. 云任务调度程序*/private CloudletScheduler cloudletScheduler;/* The host.主机 */private Host host;/* In migration flag. 迁移标志*/private boolean inMigration;/* The current allocated size.当前分配大小 */private long currentAllocatedSize;/* The current allocated ram. 当前分配内存*/private int currentAllocatedRam;/* The current allocated bw. 当前分配带宽*/private long currentAllocatedBw;/* The current allocated mips. 当前分配mips*/private List currentAllocatedMips;/* The recently created. 最近创建*/private boolean recentlyCreated;/*【虚拟机特征对象】 * Creates a new VMCharacteristics object. * * param id unique ID of the VM * param userId ID of the VMs owner * param size amount of storage * param ram amount of ram * param bw amount of bandwidth * param pesNumber amount of CPUs CPU总和 * param vmm virtual machine monitor 虚拟机监控器 * param cloudletScheduler cloudletScheduler policy for cloudlets云任务调度协议 * param priority the priority 优先权 * param mips the mips * * pre id = 0 * pre userId = 0 * pre size 0 * pre ram 0 * pre bw 0 * pre cpus 0 * pre priority = 0 * pre cloudletScheduler != null * post $none */public Vm(int id, int userId, double mips, int pesNumber, int ram, long bw, long size, String vmm, CloudletScheduler cloudletScheduler) setId(id);setUserId(userId);setUid(getUid(userId, id);setMips(mips);setPesNumber(pesNumber);setRam(ram);setBw(bw);setSize(size);setVmm(vmm);setCloudletScheduler(cloudletScheduler);setInMigration(false);setRecentlyCreated(true);setCurrentAllocatedBw(0);setCurrentAllocatedMips(null);/怎么是nullsetCurrentAllocatedRam(0);setCurrentAllocatedSize(0);/*【更新运行在虚拟机上云任务】 * Updates the processing of cloudlets running on this VM. * * param currentTime current simulation time * param mipsShare array with MIPS share of each Pe available to the scheduler * * return time predicted completion time【预测完成时间】 of the earliest finishing cloudlet, or 0 * if there is no next events * * pre currentTime = 0 * post $none */public double updateVmProcessing(double currentTime, List mipsShare) if (mipsShare != null) return getCloudletScheduler().updateVmProcessing(currentTime, mipsShare);return 0.0;/*当前请求的MIPS * Gets the current requested mips. * * return the current requested mips */public List getCurrentRequestedMips() List currentRequestedMips = getCloudletScheduler().getCurrentRequestedMips();if (isRecentlyCreated() /新创建虚拟机boolean mipsIsNull = true;for (double mips : currentRequestedMips) if (mips 0.0) mipsIsNull = false;setRecentlyCreated(false);break;/if (mipsIsNull & isRecentlyCreated() if (mipsIsNull) currentRequestedMips = new ArrayList();for (int i = 0; i 0 * post $none */public void setRam(int ram) this.ram = ram;/*总带宽 * Gets the amount of bandwidth. * * return amount of bandwidth * * pre $none * post $none */public long getBw() return bw;/*设置带宽 * Sets the amount of bandwidth. * * param bw new amount of bandwidth * * pre bw 0 * post $none */public void setBw(long bw) this.bw = bw;/*取存储 * Gets the amount of storage. * * return amount of storage * * pre $none * post $none */public long getSize() return size;/*设置存储 * Sets the amount of storage. * * param size new amount of storage * * pre size 0 * post $none */public void setSize(long size) this.size = size;/*取VMM * Gets the VMM. * * return VMM * * pre $none * post $none */public String getVmm()return vmm;/*设置VMM * Sets the VMM. * * param vmm the new VMM */protected void setVmm(String vmm) this.vmm = vmm;/*设置主机 * Sets the host that runs this VM. * * param host Host running the VM * * pre host != $null * post $none */public void setHost(Host host)this.host = host;/*获取主机 * Gets the host. * * return the host */public Host getHost() return host;/*虚拟机调度程序 * Gets the vm scheduler. * * return the vm scheduler */public CloudletScheduler getCloudletScheduler() return cloudletScheduler;/*设置虚拟机调度程序 * Sets the vm scheduler. * * param cloudletScheduler the new vm scheduler */protected void setCloudletScheduler(CloudletScheduler cloudletScheduler) this.cloudletScheduler = cloudletScheduler;/*是否迁移 * Checks if is in migration. * * return true, if is in migration */public boolean isInMigration() return inMigration;/* * Sets the in migration. * * param inMigration the new in migration */public void setInMigration(boolean inMigration) this.inMigration = inMigration;/*当前分配大小 * Gets the current allocated size. * * return the current allocated size */public long getCurrentAllocatedSize() return currentAllocatedSize;/* * Sets the current allocated size. * * param currentAllocatedSize the new current allocated size */protected void setCurrentAllocatedSize(long currentAllocatedSize) this.currentAllocatedSize = currentAllocatedSize;/*取当前分配的内存 * Gets the current allocated ram. * * return the current allocated ram */public int getCurrentAllocatedRam() return currentAllocatedRam;/*设置当前分配的内存 * Sets the current allocated ram. * * param currentAllocatedRam the new current allocated ram */public void setCurrentAllocatedRam(int currentAllocatedRam) this.currentAllocatedRam = currentAllocatedRam;/*取当前分配的带宽 * Gets the current allocated bw. * * return the current allocated bw */public long getCurrentAllocatedBw() return currentAllocatedBw;/*设置当前分配的带宽 * Sets the current allocated bw. * * param currentAllocatedBw the new current allocated bw */public void setCurrentAllocatedBw(long currentAllocatedBw) this.currentAllocatedBw = currentAllocatedBw;/*取当前分配的M

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论