CloudSim源代码学习之DatacenterCharacteristicsWord下载.docx
- 文档编号:22402591
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:21
- 大小:19.76KB
CloudSim源代码学习之DatacenterCharacteristicsWord下载.docx
《CloudSim源代码学习之DatacenterCharacteristicsWord下载.docx》由会员分享,可在线阅读,更多相关《CloudSim源代码学习之DatacenterCharacteristicsWord下载.docx(21页珍藏版)》请在冰豆网上搜索。
privateStringarchitecture;
/**Theos.操作系统*/
privateStringos;
/**Thehostlist.主机列表*/
privateList<
?
extendsHost>
hostList;
/**Thetimezone--differencefromGMT.时区*/
privatedoubletimeZone;
/**Price/CPU-unitifunit=sec.,thenG$/CPU-sec.每秒费用*/
privatedoublecostPerSecond;
/**ResourceTypes--allocationpolicy.分配协议*/
privateintallocationPolicy;
/**Time-sharedsystemusingRound-Robinalgorithm.【使用循环算法的时间共享系统】*/
publicstaticfinalintTIME_SHARED=0;
/**Spaced-sharedsystemusingFirstComeFirstServe(FCFS)algorithm.【使用先来先服务算法的空间共享系统】*/
publicstaticfinalintSPACE_SHARED=1;
/**AssumingallPEsinallMachineshavethesamerating.*/
publicstaticfinalintOTHER_POLICY_SAME_RATING=2;
/**AssumingallPEsinaMachinehavethesamerating.However,eachMachinehasdifferentratingtoeachother.*/
publicstaticfinalintOTHER_POLICY_DIFFERENT_RATING=3;
/**AresourcethatsupportsAdvancedReservationmechanisms.【支持预留机制】*/
publicstaticfinalintADVANCE_RESERVATION=4;
/**Thevmm.虚拟机管理程序*/
privateStringvmm;
/**Thecostpermem.每内存费用*/
privatedoublecostPerMem;
/**Thecostperstorage.每存储费用*/
privatedoublecostPerStorage;
/**Thecostperbw.每带宽费用*/
privatedoublecostPerBw;
/**【分配一新的数据中心特征对象】
*AllocatesanewDatacenterCharacteristicsobject.
*Ifthetimezoneisinvalid,thenbydefault,itwillbeGMT+0.默认时区
*@paramarchitecturethearchitectureofaresource
*@paramostheoperatingsystemused
*@paramvmmthevirtualmachinemonitorused
*@paramhostListlistofmachinesinaresource
*@paramtimeZonelocaltimezoneofauserthatownsthisreservation(预约时区).
*Timezoneshouldbeofrange[GMT-12...GMT+13]
*@paramcostPerSecthecostpersectousethisresource
*@paramcostPerMemthecosttousememoryinthisresource
*@paramcostPerStoragethecosttousestorageinthisresource
*@paramcostPerBwthecostperbw
*@prearchitecture!
=null
*@preOS!
*@preVMM!
*@premachineList!
*@pretimeZone>
=-12&
&
timeZone<
=13
*@precostPerSec>
=0.0
*@precostPerMem>
=0
*@precostPerStorage>
*@post$none
publicDatacenterCharacteristics(
Stringarchitecture,
Stringos,
Stringvmm,
List<
hostList,
doubletimeZone,
doublecostPerSec,
doublecostPerMem,
doublecostPerStorage,
doublecostPerBw){
setId(-1);
setArchitecture(architecture);
setOs(os);
setHostList(hostList);
setAllocationPolicy(allocationPolicy);
setCostPerSecond(costPerSec);
setTimeZone(0.0);
setVmm(vmm);
setCostPerMem(costPerMem);
setCostPerStorage(costPerStorage);
setCostPerBw(costPerBw);
}
/**【资源名】
*Getsthenameofaresource.
*@returntheresourcename
*@pre$none
*@post$result!
publicStringgetResourceName(){
returnCloudSim.getEntityName(getId());
/**【至少有一个空闲PE的机器】
*GetsaMachinewithatleastoneemptyPe.
*@returnaMachineobjectorifnotfound
publicHostgetHostWithFreePe(){
returnHostList.getHostWithFreePe(getHostList());
/**【给定空闲PE数的机器】
*GetsaMachinewithatleastagivennumberoffreePe.
*@parampeNumberthepenumber
publicHostgetHostWithFreePe(intpeNumber){
returnHostList.getHostWithFreePe(getHostList(),peNumber);
/**【PE的MIPS】
*GetsMillionsInstructionsPerSecond(MIPS)RatingofaProcessing
*Element(Pe).ItisassumedallPEs'
ratingissameinagivenmachine.
*@returntheMIPSRatingorifnoPEsareexists.
*@post$result>
=-1
@SuppressWarnings("
unchecked"
)
publicintgetMipsOfOnePe(){
if(getHostList().size()==0){
return-1;
returnPeList.getMips((List<
Pe>
)getHostList().get(0).getPeList(),0);
/**资源异构时的获取PE的MIPS之方法....
*Element(Pe).
*Itisessentialtousethismethodwhenaresourceismadeup
*ofheterogenousPEs/machines.
*@paramidthemachineID
*@parampeIdthePeID
*@preid>
*@prepeID>
publicintgetMipsOfOnePe(intid,intpeId){
)HostList.getById(getHostList(),id).getPeList(),peId);
/**【一个资源的MIPS之和】
*GetsthetotalMIPSrating,whichisthesumofMIPSratingofall
*machinesinaresource.
*<
p>
*TotalMIPSratingfor:
ul>
li>
TimeShared=1RatingofaPe*TotalnumberofPEs
Otherpolicysamerating=sameasTimeShared
SpaceShared=SumofallPEsinallMachines
Otherpolicydifferentrating=sameasSpaceShared
AdvanceReservation=0orunknown.
*Youneedtocalculatethismanually.手动计算
/ul>
*@returnthesumofMIPSratings
publicintgetMips(){
intmips=0;
switch(getAllocationPolicy()){
//AssumingallPEsinallMachinehavesamerating.假设所有机器里的PE有同样的速率
caseDatacenterCharacteristics.TIME_SHARED:
caseDatacenterCharacteristics.OTHER_POLICY_SAME_RATING:
mips=getMipsOfOnePe()*HostList.getPesNumber(getHostList());
break;
//不同的机器有不同速率AssumingallPEsinagivenMachinehavethesamerating.
//ButdifferentmachinesinaClustercanhavedifferentrating
caseDatacenterCharacteristics.SPACE_SHARED:
caseDatacenterCharacteristics.OTHER_POLICY_DIFFERENT_RATING:
for(Hosthost:
getHostList()){
mips+=host.getTotalMips();
}
default:
returnmips;
/**《时间共享》CPU时间
*GetstheCPUtimegiventhespecifiedparameters(onlyforTIME_SHARED).
tt>
NOTE:
<
/tt>
TheCPUtimeforSPACE_SHAREDandADVANCE_RESERVATION
*arenotyetimplemented.
*@paramcloudletLengththelengthofaCloudlet云任务长度
*@paramloadtheloadofaCloudlet云任务负载
*@returntheCPUtime
*@precloudletLength>
*@preload>
publicdoublegetCpuTime(doublecloudletLength,doubleload){
doublecpuTime=0.0;
cpuTime=cloudletLength/(getMipsOfOnePe()*(1.0-load));
//load怎么算?
returncpuTime;
/**【PE总数】
*GetsthetotalnumberofPEsforallMachines.
*@returnnumberofPEs
publicintgetPesNumber(){
returnHostList.getPesNumber(getHostList());
/**【空闲PE总数】
*Getsthetotalnumberof<
FREE<
ornon-busyPEsforallMachines.
publicintgetFreePesNumber(){
returnHostList.getFreePesNumber(getHostList());
/**【机器PE总数】
BUSY<
PEsforallMachines.
publicintgetBusyPesNumber(){
returnHostList.getBusyPesNumber(getHostList());
/**【设置PE状态】
*SetstheparticularPestatusonaMachine.
*@paramstatusPestatus,either<
Pe.FREE<
or<
Pe.BUSY<
*@paramhostIdMachineID
*@parampeIdPeid
*@return
*otherwise(MachineidorPeidmightnotbeexist)
*@premachineID>
publicbooleansetPeStatus(intstatus,inthostId,intpeId){
returnHostList.setPeStatus(getHostList(),status,hostId,peId);
/**【每MillionsInstruction的花费】
*GetsthecostperMillionsInstruction(MI)associatedwitharesource.
*@returnthecostusingaresource
publicdoublegetCostPerMi(){
returngetCostPerSecond()/getMipsOfOnePe();
/**【机器总数】
*Getsthetotalnumberofmachines.
*@returntotalnumberofmachinesthisresourcehas.
publicintgetHostsNumber(){
returngetHostList().size();
/**【当前失效的机器】
*Getsthecurrentnumberoffailedmachines.
*@returncurrentnumberoffailedmachinesthisresourcehas.
publicintgetFailedHostsNumber(){
intfailedHostsNumber=0;
for(Hosthost:
if(host.isFailed()){
failedHostsNumber++;
returnfailedHostsNumber;
/**【检查机器是否工作正常】
*Checkswhetherallmachinesofthisresourceareworkingproperlyornot.
*@returnifallmachinesareworking,
*otherwise
publicbooleanisWorking(){
booleanresult=false;
if(getFailedHostsNumber()==0){
result=true;
returnresult;
/**【使用资源的内存花费】
*Getthecosttousememoryinthisresource.
*@returnthecosttousememory
publicdoublegetCostPerMem(){
returncostPerMem;
/**【设置
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CloudSim 源代码 学习 DatacenterCharacteristics
链接地址:https://www.bdocx.com/doc/22402591.html