CloudSim源代码学习SimEntityjava.docx

上传人:b****4 文档编号:3125924 上传时间:2022-11-17 格式:DOCX 页数:23 大小:19.02KB
下载 相关 举报
CloudSim源代码学习SimEntityjava.docx_第1页
第1页 / 共23页
CloudSim源代码学习SimEntityjava.docx_第2页
第2页 / 共23页
CloudSim源代码学习SimEntityjava.docx_第3页
第3页 / 共23页
CloudSim源代码学习SimEntityjava.docx_第4页
第4页 / 共23页
CloudSim源代码学习SimEntityjava.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

CloudSim源代码学习SimEntityjava.docx

《CloudSim源代码学习SimEntityjava.docx》由会员分享,可在线阅读,更多相关《CloudSim源代码学习SimEntityjava.docx(23页珍藏版)》请在冰豆网上搜索。

CloudSim源代码学习SimEntityjava.docx

CloudSim源代码学习SimEntityjava

SimEntity.java

/*

该类表示一个模拟实体。

实体处理事件并且发送事件到其他实体。

*Title:

CloudSimToolkit

*Description:

CloudSim(CloudSimulation)ToolkitforModelingandSimulationofClouds

*Licence:

GPL-/gpl.html

*

*Copyright(c)2009-2010,TheUniversityofMelbourne,Australia

*/

package;

import;

import;

import;

/**

*Thisclassrepresentsasimulationentity.Anentityhandleseventsandcan

*sendeventstootherentities.Whenthisclassisextended,thereareafew

*methodsthatneedtobeimplemented:

*

    *

  • {@link#startEntity()}isinvokedbythe{@linkSimulation}classwhen

    *thesimulationisstarted.Thismethodshouldberesponsibleforstartingthe

    *entityup.

    *

  • {@link#processEvent(SimEvent)}isinvokedbythe{@linkSimulation}

    *classwheneverthereisaneventinthedeferredqueue,whichneedstobe

    *processedbytheentity.

    *

  • {@link#shutdownEntity()}isinvokedbythe{@linkSimulation}beforethe

    *simulationfinishes.Ifyouwanttosavedatainlogfilesthisisthemethod

    *inwhichthecorrespondingcodewouldbeplaced.

    *

*

*@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

*tag9999isreserved.

*

*@paramdestTheuniqueidnumberofthedestinationentity

*@paramdelayHowlongfromthecurrentsimulationtimetheevent

*shouldbesent

*@paramtagAnuser-definednumberrepresentingthetypeofevent.

*@paramdataThedatatobesentwiththeevent.

*/

publicvoidschedule(intdest,doubledelay,inttag,Objectdata){

if(!

CloudSim.running()){

return;

}

CloudSim.send(id,dest,delay,tag,data);

}

/**

*Sendaneventtoanotherentitybyidnumberandwithnodata.

*Notethatthetag9999isreserved.

*

*@paramdestTheuniqueidnumberofthedestinationentity

*@paramdelayHowlongfromthecurrentsimulationtimetheevent

*shouldbesent

*@paramtagAnuser-definednumberrepresentingthetypeofevent.

*/

publicvoidschedule(intdest,doubledelay,inttag){

schedule(dest,delay,tag,null);

}

/**

*Sendaneventtoanotherentitythroughaportwithagivenname,with

*data.Notethatthetag9999isreserved.

*

*@paramdestThenameoftheporttosendtheeventthrough

*@paramdelayHowlongfromthecurrentsimulationtimetheevent

*shouldbesent

*@paramtagAnuser-definednumberrepresentingthetypeofevent.

*@paramdataThedatatobesentwiththeevent.

*/

publicvoidschedule(Stringdest,doubledelay,inttag,Objectdata){

schedule(CloudSim.getEntityId(dest),delay,tag,data);

}

/**

*Sendaneventtoanotherentitythroughaportwithagivenname,with

*nodata.Notethatthetag9999isreserved.

*

*@paramdestThenameoftheporttosendtheeventthrough

*@paramdelayHowlongfromthecurrentsimulationtimetheeventshouldbe

*sent

*@paramtagAnuser-definednumberrepresentingthetypeofevent.

*/

publicvoidschedule(Stringdest,doubledelay,inttag){

schedule(dest,delay,tag,null);

}

/**

*Sendaneventtoanotherentitybyidnumber,withdata.Notethatthe

*tag9999isreserved.

*

*@paramdestTheuniqueidnumberofthedestinationentity

*@paramtagAnuser-definednumberrepresentingthetypeofevent.

*@paramdataThedatatobesentwiththeevent.

*/

publicvoidscheduleNow(intdest,inttag,Objectdata){

schedule(dest,0,tag,data);

}

/**

*Sendaneventtoanotherentitybyidnumberandwithnodata.

*Notethatthetag9999isreserved.

*

*@paramdestTheuniqueidnumberofthedestinationentity

*@paramtagAnuser-definednumberrepresentingthetypeofevent.

*/

publicvoidscheduleNow(intdest,inttag){

schedule(dest,0,tag,null);

}

/**

*Sendaneventto

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1