CloudSim源代码学习SimEntityjava文档格式.docx
- 文档编号:16036860
- 上传时间:2022-11-17
- 格式:DOCX
- 页数:23
- 大小:19.02KB
CloudSim源代码学习SimEntityjava文档格式.docx
《CloudSim源代码学习SimEntityjava文档格式.docx》由会员分享,可在线阅读,更多相关《CloudSim源代码学习SimEntityjava文档格式.docx(23页珍藏版)》请在冰豆网上搜索。
*
*Copyright(c)2009-2010,TheUniversityofMelbourne,Australia
*/
package;
import;
/**
*Thisclassrepresentsasimulationentity.Anentityhandleseventsandcan
*sendeventstootherentities.Whenthisclassisextended,thereareafew
*methodsthatneedtobeimplemented:
*<
ul>
li>
{@link#startEntity()}isinvokedbythe{@linkSimulation}classwhen
*thesimulationisstarted.Thismethodshouldberesponsibleforstartingthe
*entityup.
{@link#processEvent(SimEvent)}isinvokedbythe{@linkSimulation}
*classwheneverthereisaneventinthedeferredqueue,whichneedstobe
*processedbytheentity.
{@link#shutdownEntity()}isinvokedbythe{@linkSimulation}beforethe
*simulationfinishes.Ifyouwanttosavedatainlogfilesthisisthemethod
*inwhichthecorrespondingcodewouldbeplaced.
/ul>
*@authorMarcosDiasdeAssuncao
*@sinceCloudSimToolkit1.0
publicabstractclassSimEntityimplementsCloneable{
/**Thename.*/
privateStringname;
/**Theid.*/
privateintid;
/**Thebufferforselectedincomingevents.*/
privateSimEventevbuf;
/**Theentity'
scurrentstate.*/
privateintstate;
/**
*Createsanewentity.
*@paramnamethenametobeassociatedwiththisentity
publicSimEntity(Stringname){
if(name.indexOf("
"
)!
=-1){
thrownewIllegalArgumentException(
"
Entitynamescan'
tcontainspaces."
);
}
this.name=name;
id=-1;
state=RUNNABLE;
CloudSim.addEntity(this);
}
*Getthenameofthisentity.
*@returnTheentity'
sname
publicStringgetName(){
returnname;
*Gettheuniqueidnumberassignedtothisentity.
*@returnTheidnumber
publicintgetId(){
returnid;
//Theschedulefunctions
*Sendaneventtoanotherentitybyidnumber,withdata.Notethatthe
*tag<
code>
9999<
/code>
isreserved.
*@paramdestTheuniqueidnumberofthedestinationentity
*@paramdelayHowlongfromthecurrentsimulationtimetheevent
*shouldbesent
*@paramtagAnuser-definednumberrepresentingthetypeofevent.
*@paramdataThedatatobesentwiththeevent.
publicvoidschedule(intdest,doubledelay,inttag,Objectdata){
if(!
CloudSim.running()){
return;
CloudSim.send(id,dest,delay,tag,data);
*Sendaneventtoanotherentitybyidnumberandwith<
b>
no<
/b>
data.
*Notethatthetag<
publicvoidschedule(intdest,doubledelay,inttag){
schedule(dest,delay,tag,null);
*Sendaneventtoanotherentitythroughaportwithagivenname,with
*data.Notethatthetag<
*@paramdestThenameoftheporttosendtheeventthrough
publicvoidschedule(Stringdest,doubledelay,inttag,Objectdata){
schedule(CloudSim.getEntityId(dest),delay,tag,data);
data.Notethatthetag<
*@paramdelayHowlongfromthecurrentsimulationtimetheeventshouldbe
*sent
publicvoidschedule(Stringdest,doubledelay,inttag){
publicvoidscheduleNow(intdest,inttag,Objectdata){
schedule(dest,0,tag,data);
publicvoidscheduleNow(intdest,inttag){
schedule(dest,0,tag,null);
*Sendaneventto
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CloudSim 源代码 学习 SimEntityjava