Search code examples
javatimecloudcloudsim

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 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.

Solution

  • 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.