如何为CloudSim Plus中的Cloudlet设置非相对提交延迟?

huangapple go评论67阅读模式
英文:

How to set non-relative submission delay for Cloudlets in CloudSim Plus?

问题

I'd like to delay the arrival of the Cloudlet so that they arrive later. I know about setSubmissionDelay() but I wanted a submission delay that is not relative to the current simulation time like setSubmissionDelay() is. For example, if a cloudlet has a delay of 5 seconds it will be created exactly at that time and not at something like 5.10 seconds (.10 seconds being from the minimum time between events). I've thought about using a listener to listen and intercept when a cloudlet is about to be submitted to a VM to grab time at that moment (it would likely be .10 or some small-time value), then subtract my delay time by that time (current delay of a cloudlet - current simulation time = non-relative submission delay).

The issue is I can't find a listener that does this. Looking at the console output below makes me think that maybe a listener or some kind of method is used to print, a cloudlet is being sent before it is. If something like this exists, I'd like to use it. Any access to documentation or repositories similar goals will be highly appreciated.

Reference: https://github.com/manoelcampos/cloudsim-plus/tree/master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim

[0;39m[34mINFO 0.10: DatacenterBrokerSimple2: Sending Cloudlet 0 to Vm 0 in Host 0/DC 1 with a requested delay of 9 seconds.

英文:

I'd like to delay the arrival of the Cloudlet so that they arrive later. I know about setSubmissionDelay() but I wanted a submission delay that is not relative to the current simulation time like setSubmissionDelay() is. For example, if a cloudlet has a delay of 5 seconds it will be created exactly at that time and not at something like 5.10 seconds (.10 seconds being from the minimum time between events). I've thought about using a listener to listen and intercept when a cloudlet is about to be submitted to a VM to grab time at that moment (it would likely by .10 or some small-time value), then subtract my delay time by that time (current delay of a cloudlet - current simulation time = non-relative submission delay).

The issue is I can't find a listener that does this. Looking at the console output below makes me think that maybe a listener or some kind of method is used to print, a cloudlet is being sent before it is. If something like this exists, I'd like to use it. Any access to documentation or repositories similar goals will be highly appreciated.

Reference: https://github.com/manoelcampos/cloudsim-plus/tree/master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim

[0;39m[34mINFO  0.10: DatacenterBrokerSimple2: Sending Cloudlet 0 to Vm 0 in Host 0/DC 1 with a requested delay of 9 seconds.

答案1

得分: 2

public class Example{
    private static final int SCHEDULING_INTERVAL = 1; //以秒为单位

    public Example(){
       //.......... 在这里实例化模拟对象

       datacenter0.setSchedulingInterval(SCHEDULING_INTERVAL); 
       simulation.addOnClockTickListener(this::clockTickListener);

       //.......... 其余模拟代码在这里
    }

    private void clockTickListener(final EventInfo info) {
        final int seconds = (int)info.getTime();

        if(seconds == 5) {
           //创建并提交您的Cloudlet
        }
    }
}

更多详细信息,请查看RandomCloudletsArrivalExample.java

英文:

Do you really need such a precision? 0.1 second is a really small value.
Anyway, you can set a Datacenter schedulingInterval to the minimum interval you want (for instance, 1 second), then use the CloudSim Plus' onClockTickListener to track the simulation time and submit your cloudlets when you want. See the code snippet below, but you have no guarantees that the event will be fired exactly at the times you want.


public class Example{
    private static final int SCHEDULING_INTERVAL = 1; //in seconds

    public Example(){
       //.......... instantiate simulation objects here

       datacenter0.setSchedulingInterval(SCHEDULING_INTERVAL); 
       simulation.addOnClockTickListener(this::clockTickListener);

       //.......... the rest of the simulation code here
    }

    private void clockTickListener(final EventInfo info) {
        final int seconds = (int)info.getTime();

        if(seconds == 5) {
           //create and submit your cloudlets
        }
    }
}

Check the RandomCloudletsArrivalExample.java for more details.

huangapple
  • 本文由 发表于 2020年3月15日 07:52:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/60688449.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定