我正在研究 Cloudsim。如何将 cloudlet 提交延迟 30 秒?30 秒后第一个 cloudlet 提交后,第二个 cloudlet 必须开始执行。
有没有办法做到这一点?
要在 CloudSim 中的小云之间添加一些延迟,您需要访问“DatacenterBroker”类中的“submitCloudLets”方法。在方法“submitCloudlets”中,您需要访问和编辑方法“sendNow”。应插入以下示例代码:
protected void sendNow(int entityId, int cloudSimTag, Object data) {
if(cloudSimTag==CloudSimTags.CLOUDLET_SUBMIT){
send(entityId, delay /* enter your delay value here or call a method that calculates the delay value randomly */, cloudSimTag, data);
}
else send(entityId, 0, cloudSimTag, data); // CASE the cloudsim tag was not "CLOUDLET_SUBMIT". !!! If you remove this line, your program does not work!!!!
}
我不确定 Cloudsim 的 api,如果您只需要使用代码添加时间延迟,您也可以使用 java..
利用
Thread.sleep(3000);
您可以在文档http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#sleep(long , int)中阅读有关它的更多信息
在 submitCloudlets 方法中的数据中心代理类中,注释 SendNow 函数并使用 send 函数。
这个函数有一个延迟参数。将延迟更改为您想要的时间。然后,如果您使用 cloudlet 的 getSubmissionTime ,您将获得此参数。
CloudSim Plus 本身就支持这样的功能。您只需要进行这个单一的方法调用broker.submitCloudletList(cloudletList, submissionDelay)
,Cloudlets 将仅在给定的延迟(以秒为单位)之后提交。
这样,您无需更改框架代码即可实现这样的基本功能。如果您更改框架的类以包含仅用于模拟的基本功能,您可能很难将框架的分支更新为最新版本。
检查https://cloudsimplus.org#main-exclusive-features上的功能 #8 以了解更多详细信息。