Cloud computing simulation tool Chinese annotation datacentercharacteristics. 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. list; import Org. cloudid. cloudsim. core. cloudsim; import Org. cloudid. cloudsim. lists. hostlist; import Org. cloudid. Cloudsim. lists. pelist;/*** indicates some static attributes of datacenter * method: * search for qualified hosts * obtain some price parameters * obtain the status, quantity, and host of some PES, quantity info ** datacentercharacteristics represents static properties of a * resource such as resource architecture, operating system (OS), Management * Policy (time-or space-shared ), cost and time zone at which the resource * is located along resource configuration. ** @ author manzur Murshed * @ author Rajkumar buyya * @ author Rodrigo n. calheiros * @ author Anton beloglazov * @ since cloudsim toolkit 1.0 */public class datacentercharacteristics {/** the resource id -- setup when resource is created. */private int ID;/** the architecture. */private string architecture;/** the OS. */private string OS;/** the host list. */private list <? Extends host> hostlist;/** the time zone -- difference from GMT. */private double timezone;/** price/CPU-unit if unit = sec ., then G $/CPU-Sec. */private double costpersecond;/** resource types -- Allocation Policy. */private int allocationpolicy;/** time-shared system using round-round robin (Round Robin) algorithm. */public static final int time_shared = 0;/** spaced-shared system using first come firs T serve (FCFS) algorithm. */public static final int space_shared = 1;/** assuming all PES in all machines have the same rating. */public static final int other_policy_same_rating = 2;/** assuming all PES in a machine have the same rating. however, each machine has different rating to each other. */public static final int other_policy_different_rating = 3;/*** accept the advance reservation Mechanism * a resource that supp Orts advanced reservation mechanisms. */public static final int advance_reservation = 4;/** the vmm. */private string vmm;/** the cost per mem. */private double costpermem;/** the cost per storage. */private double costperstorage;/** the cost per BW. */private double costperbw;/*** allocates a new datacentercharacteristics object. * If the time zone is invalid, then by default, it will Be GMT + 0. ** @ Param architecture the architecture of a resource * @ Param OS the operating system used * @ Param vmm the Virtual Machine monitor used * @ Param hostlist list of machines in a resource * @ Param timezone local time zone of a user that owns this reservation. * Time Zone shoshould be of range [GMT-12... GMT + 13] * @ Param costpersec the cost per sec to use this resource * @ Param costpermem t He cost to use memory in this resource * @ Param costperstorage the cost to use storage in this resource * @ Param costperbw the cost per BW ** @ pre architecture! = NULL * @ pre OS! = NULL * @ pre vmm! = NULL * @ pre machinelist! = NULL * @ pre timezone> =-12 & timezone <= 13 * @ pre costpersec> = 0.0 * @ pre costpermem> = 0 * @ pre costperstorage> = 0 * @ post $ none */Public datacentercharacteristics (string architecture, string OS, string vmm, list <? Extends host> hostlist, double timezone, double costpersec, double costpermem, double costperstorage, double costperbw) {setid (-1); setarchitecture (Architecture); setos (OS ); sethostlist (hostlist); setallocationpolicy (allocationpolicy); Response (costpersec); settimezone (0.0); setvmm (vmm); setcostpermem (costpermem); setcostperstorage (costperstorage ); setcostperbw (costperbw);}/*** gets th E name of a resource. ** @ return the Resource Name ** @ pre $ none * @ post $ result! = NULL */Public String getresourcename () {return cloudsim. getentityname (GETID ();}/*** gets a machine with at least one empty PE. * obtain a machine with an idle Pe * @ return a machine object or if not found * @ pre $ none * @ post $ none */public host gethostwithfreepe () {return hostlist. gethostwithfreepe (gethostlist ();}/*** machines with a given number of PES * gets a machine with at least a given number of free PE. ** @ Param penumber the Pe NUMBER * @ return a machine object or if not found * @ pre $ none * @ post $ none */public host gethostwithfreepe (INT penumber) {return hostlist. gethostwithfreepe (gethostlist (), penumber);}/*** get the computing power of Pe * gets millions instructions per second (MIPs) rating of a processing * element (PE ). it is assumed all PES 'rating is same in a given machine. ** @ return the MIPs rating or if no PES are exists. * @ pre $ none * @ post $ result> =-1 */@ suppresswarnings ("unchecked") Public int getmipsofonepe () {If (gethostlist (). size () = 0) {return-1;} return pelist. getmips (list <PE>) gethostlist (). get (0 ). getpelist (), 0);}/*** specifies the MIPs * gets millions instructions per second (MIPs) rating of a processing * element (PE) of the PE on the machine ). * It is essential to use this method when a resource is made up * of heterogenous PES/machines. ** @ Param ID the machine ID * @ Param peid the pe id * @ return the MIPs rating or if no PES are exists. * @ pre ID> = 0 * @ pre peid> = 0 * @ post $ result> =-1 */@ suppresswarnings ("unchecked") Public int getmipsofonepe (int id, int peid) {If (gethostlist (). size () = 0) {return-1;} return pelist. getmips (list <PE>) hostlist. getbyid (gethostlist (), ID ). getpelist (), peid);}/*** get the entire MIPS * gets the total MIPS rating, which is the sum of MIPS rating of all * machines in a resource. * <p> * Total MIPS rating: * <ul> * <li> timeshared = 1 rating of a Pe * Total Number of PES * <li> Other Policy same rating = same as timeshared * <li> spaceshared = sum all PES in all machines * <li> other policy different rating = same as spaceshared * <li> advance reservation = 0 or unknown. * You need to calculate this manually. * </ul> ** @ return the sum of MIPS ratings ** @ pre $ none * @ post $ result> = 0 */Public int getmips () {int MIPS = 0; Switch (getallocationpolicy () {// assuming all PES in all machine have same rating. case datacentercharacteristics. time_shared: Case datacentercharacteristics. other_policy_same_rating: MIPS = getmipsofonepe () * hostlist. getpesnumber (gethostlist (); break; // assuming all PES in a given machine have the same rating. // but different machines in a cluster can have different rating case datacentercharacteristics. space_shared: Case datacentercharacteristics. other_policy_different_rating: For (host HOST: gethostlist () {MIPS + = host. gettotalmips ();} break; default: break;} return MIPS;}/*** gets the CPU time given the specified parameters (only for time_shared ). * <tt> Note: </tt> the CPU time for space_shared and advance_reservation * are not yet implemented. ** @ Param cloudletlength the length of a cloudlet * @ Param load the load of a cloudlet ** @ return the CPU time ** @ pre cloudletlength >=0.0 * @ pre load> = 0.0 * @ post $ result> = 0.0 */Public double getcputime (double cloudletlength, double load) {double cputime = 0.0; Switch (getallocationpolicy () {Case datacentercharacteristics. time_shared: cputime = cloudletlength/(getmipsofonepe () * (1.0-load); break; default: break;} return cputime ;} /*** gets the total number of PES for all machines. ** @ return number of PES ** @ pre $ none * @ post $ result> = 0 */Public int getpesnumber () {return hostlist. getpesnumber (gethostlist ();}/*** gets the total number of <tt> free </tt> or non-busy PES for all machines. ** @ return number of PES ** @ pre $ none * @ post $ result> = 0 */Public int getfreepesnumber () {return hostlist. getfreepesnumber (gethostlist ();}/*** gets the total number of <tt> busy </tt> PES for all machines. ** @ return number of PES ** @ pre $ none * @ post $ result> = 0 */Public int getbusypesnumber () {return hostlist. getbusypesnumber (gethostlist ();}/*** sets the participating PE status on a machine. ** @ Param status PE status, either <tt> PE. free </tt> or <tt> PE. busy </tt> * @ Param hostid machine ID * @ Param peid pe id * @ return * otherwise (machine ID or pe id might not be exist) * @ pre machineid> = 0 * @ pre peid> = 0 * @ post $ none */Public Boolean setpestatus (INT status, int hostid, int peid) {return hostlist. setpestatus (gethostlist (), status, hostid, peid);}/*** gets the cost per millions instruction (MI) associated with a resource. ** @ return the cost using a resource ** @ pre $ none * @ post $ result> = 0.0 */Public double getcostpermi () {return getcostpersecond () /getmipsofonepe ();}/*** gets the total number of machines. ** @ return total number of machines this resource has. */Public int gethostsnumber () {return gethostlist (). size ();}/*** gets the current number of failed machines. ** @ return current number of failed machines this resource has. */Public int getfailedhostsnumber () {int failedhostsnumber = 0; For (host HOST: gethostlist () {If (host. isfailed () {failedhostsnumber ++;} return failedhostsnumber;}/*** checks whether all machines of this resource are working properly or not. ** @ return if all machines are working, * otherwise */Public Boolean isworking () {boolean result = false; If (getfailedhostsnumber () = 0) {result = true ;} return result;}/*** get the cost to use memory in this resource. ** @ return the cost to use memory */Public double getcostpermem () {return costpermem;}/*** sets cost to use memory. ** @ Param costpermem cost to use memory ** @ pre costpermem> = 0 * @ post $ none */Public void setcostpermem (double costpermem) {This. costpermem = costpermem;}/*** get the cost to use storage in this resource. ** @ return the cost to use storage */Public double getcostperstorage () {return costperstorage;}/*** sets cost to use storage. ** @ Param costperstorage cost to use storage ** @ pre costperstorage> = 0 * @ post $ none */Public void setcostperstorage (double costperstorage) {This. costperstorage = costperstorage;}/*** get the cost to use bandwidth in this resource. ** @ return the cost to use BW */Public double getcostperbw () {return costperbw;}/*** sets cost to use BW. ** @ Param costperbw the cost per BW ** @ pre costperbw> = 0 * @ post $ none */Public void setcostperbw (double costperbw) {This. costperbw = costperbw;}/*** gets the vmm in use in the datacenter. ** @ return the vmm name */Public String getvmm () {return vmm;}/*** gets the ID. ** @ return the ID */protected int GETID () {return ID;}/*** sets the ID. ** @ Param ID the new ID */protected void setid (int id) {This. id = ID;}/*** gets the architecture. ** @ return the architecture */protected string getarchitecture () {return architecture;}/*** sets the architecture. ** @ Param architecture the new architecture */protected void setarchitecture (string architecture) {This. architecture = architecture;}/*** gets the OS. ** @ return the OS */protected string getos () {return OS;}/*** sets the OS. ** @ Param OS the new OS */protected void setos (string OS) {This. OS = OS;}/*** gets the host list. ** @ Param <t> the generic type * @ return the host list */@ suppresswarnings ("unchecked") Public <t extends host> List <t> gethostlist () {return (list <t>) hostlist;}/*** sets the host list. ** @ Param <t> the generic type * @ Param hostlist the new host list */protected <t extends host> void sethostlist (list <t> hostlist) {This. hostlist = hostlist;}/*** gets the time zone. ** @ return the time zone */protected double gettimezone () {return timezone;}/*** sets the time zone. ** @ Param timezone the new time zone */protected void settimezone (double timezone) {This. timezone = timezone;}/*** gets the cost per second. ** @ return the cost per second */protected double getcostpersecond () {return costpersecond;}/*** sets the cost per second. ** @ Param costpersecond the new cost per second */protected void setcostpersecond (double costpersecond) {This. costpersecond = costpersecond;}/*** gets the allocation policy. ** @ return the allocation policy */protected int getallocationpolicy () {return allocationpolicy;}/*** sets the allocation policy. ** @ Param allocationpolicy the new allocation policy */protected void setallocationpolicy (INT allocationpolicy) {This. allocationpolicy = allocationpolicy;}/*** sets the vmm. ** @ Param vmm the new vmm */protected void setvmm (string vmm) {This. vmm = vmm ;}}

 

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.