VM. Java

Source: Internet
Author: 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. cloudid. cloudsim; import Java. util. arraylist; import Java. util. list;/*** VM class indicates a virtual machine that runs in the host and shares the host with other virtual machines. Each VM * has an owner, which can submit cloudlet, the VM processes the submitted clo The main udlet * method is to update each cloudlet * 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 {/** * Parameter: * ID, user ID, hard disk size (size), processing capability, number of PES, memory, bandwidth, vmm, scheduling policy * Host, whether to migrate, allocated size, processing capability, internal and external memory, bandwidth, whether it is recently created * // ** the ID. */private int ID;/** the user ID. */private int userid; private string uid;/** the size. */private long size;/** the mips. processing capacity */private double MIPS;/** the PES number. */private int pesnumber;/** the ram. */private int Ram;/** the BW. */private long bw;/** the vmm. */private string vmm ;/** The cloudlet scheduler. cloudler scheduling policy */private cloudletscheduler;/** the host. */private host; // What if a VM requires more than one host? There should be a list./** 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 currentallocatedb W;/** the current allocated MIPS. */private list <double> currentallocatedmips;/** the recently created. */private Boolean recentlycreated;/*** creates a new vmcharacteristics object. ** @ Param ID unique ID of the VM * @ Param userid of the VM's owner * @ Param size amount of storage * @ Param RAM amount of Ram * @ Param BW amount of bandwidth * @ Param pesnumber amount of CPUs * @ Param vmm virtual Machine monitor * @ Param 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 cloudletschedity! = NULL * @ post $ none */Public VM (int id, int userid, double MIPS, int pesnumber, int Ram, long BW, long size, string vmm, cloudletscheduler) {setid (ID); setuserid (userid); setuid (getuid (userid, ID); setmips (MIPs); setpesnumber (pesnumber); setram (RAM ); setbw (BW); setsize (size); setvmm (vmm); setcloudletscheduler (cloudletschedation); setinmigration (false); setrecentlycreated (true); setcurrentall Ocatedbw (0); setcurrentallocatedmips (null); setcurrentallocatedram (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 <double> mipsshare) {If (mipsshare! = NULL) {// update return getcloudletscheduler () for cloudlet in scheduler (). updatevmprocessing (currenttime, mipsshare);} return 0.0;}/*** the newly created VM directly returns currentrequestedmips; otherwise, * gets the current requested MIPs is returned. ** @ return the current requested MIPS */public list <double> getcurrentrequestedmips () {list <double> currentrequestedmips = getcloudletschedmips (). getcurrentrequestedmips (); If (isrecentlycreated () {boo Lean mipsisnull = true; For (double MIPS: currentrequestedmips) {If (MIPs> 0.0) {mipsisnull = false; setrecentlycreated (false); break ;}} // If (mipsisnull & isrecentlycreated () {If (mipsisnull) {currentrequestedmips = new arraylist <double> (); For (INT I = 0; I <getpesnumber (); I ++) {currentrequestedmips. add (getmips () ;}}return currentrequestedmips;}/*** total processing capacity * gets the current requested total MI PS. ** @ return the current requested total MIPS */Public double getcurrentrequestedtotalmips () {double totalrequestedmips = 0; For (double MIPS: getcurrentrequestedmips () {totalrequestedmips + = MIPS ;} return totalrequestedmips;}/*** gets the current requested BW. ** @ return the current requested BW */public long getcurrentrequestedbw () {return getbw ();}/*** gets the current requested Ram. ** @ Return the current requested Ram */Public int getcurrentrequestedram () {return getram ();}/*** total CPU usage at the moment * Get utilization created by all clouddlets running on this VM. ** @ Param time the time ** @ return total utilization */Public double gettotalutilizationofcpu (double time) {return getcloudletscheduler (). gettotalutilizationofcpu (time);}/*** get utilization created by all cloudlets running on This VM in MIPS. ** @ Param time the time ** @ return total utilization */Public double gettotalutilizationofcpumips (double time) {return gettotalutilizationofcpu (time) * getmips ();} public void setuid (string UID) {This. uid = uid;}/*** get unique string identificator of the VM. ** @ return string uid */Public String getuid () {return uid;}/*** generate unique string identificator of the VM. **@ Param userid the user ID * @ Param vmid the vm id ** @ return string uid */public static string getuid (INT userid, int vmid) {return userid + "-" + vmid;}/*** gets the ID. ** @ return the ID */Public int GETID () {return ID;}/*** sets the ID. ** @ Param ID the new ID */protected void setid (int id) {This. id = ID;}/*** sets the user ID. ** @ Param userid the new user ID */protected void setuserid (I NT userid) {This. userid = userid;}/*** gets the ID of the owner of the VM. ** @ return VM's owner ID ** @ pre $ none * @ post $ none */Public int getuserid () {return userid;}/*** gets the mips. ** @ return the MIPs */Public double getmips () {return MIPS;}/*** sets the mips. ** @ Param MIPs The New MIPS */protected void setmips (double MIPS) {This. MIPs = MIPS;}/*** gets the PES number. ** @ return The PES Number */Public int getpesnumber () {return pesnumber;}/*** sets the PES number. ** @ Param pesnumber the new PES Number */protected void setpesnumber (INT pesnumber) {This. pesnumber = pesnumber;}/*** gets the amount of RAM. ** @ return amount of Ram ** @ pre $ none * @ post $ none */Public int getram () {return Ram;}/*** sets the amount of RAM. ** @ Param Ram new amount of Ram ** @ pre Ram> 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 S Torage ** @ 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;}/*** gets the vmm. ** @ return vmm ** @ pre $ none * @ post $ none */Public String getvmm () {return vmm;}/*** sets the vmm. ** @ Param vmm the new vmm */protected void setv Mm (string vmm) {This. vmm = vmm;}/*** sets the host that runs this VM. ** @ Param host running the VM ** @ pre host! = $ Null * @ post $ none */Public void sethost (host) {This. host = host;}/*** gets the host. ** @ return the host */public host gethost () {return host;}/*** gets the VM scheduler. * schedsets mainly serves some cloudlet queues * @ return the VM scheduler */Public cloudletscheduler getcloudletscheduler () {return cloudletschedsets;}/*** sets the VM schedsets. ** @ Param cloudletschedthe the new VM scheduler */protected void setcloudletscheduler (cloudletscheduler) {This. cloudletscheduler = cloudletschedation;}/*** 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;}/*** gets the current allocated MIPS. ** @ return the current allocated MIPS * @ todo replace returning the field by a call to getcloudletscheduler (). getcurrentmipsshare () */public list <double> getcurrentallocatedmips () {return currentallocatedmips;}/*** sets the current allocated MIPS. ** @ Param currentallocatedmips the new current allocated MIPS */Public void setcurrentallocatedmips (list <double> currentallocatedmips) {This. currentallocatedmips = currentallocatedmips;}/*** checks if is recently created. ** @ return true, if is recently created */Public Boolean isrecentlycreated () {return recentlycreated;}/*** sets the recently created. ** @ Param recentlycreated the new recently created */Public void setrecentlycreated (Boolean recentlycreated) {This. recentlycreated = recentlycreated ;}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.