0

I added randomly Boolean parameter among cloudlet attributes for giving preference below is the code what else can do? What parameters can be added more to cloudlet attributes for giving them priority.

    for(int i=0;i<cloudlets;i++){
        Random r= new Random(); // for creating random length
        Random priortyObj =new Random(); // for creating booleon priorty
        cloudlet[i] = new Cloudlet(priorty_cloudlet.priortyObj.nextInt(2),           
                      i, length +r.nextInt(2000),pesNumber,
                      fileSize, outputSize, utilizationModel,                                  
                      utilizationModel,  utilizationModel);
        // setting the owner of these Cloudlets
         cloudlet[i].setUserId(userId);`
         list.add(cloudlet[i]);
     }

1 Answers1

1

Priority can be dealt in two different ways: (i) we could prioritize the submission of Cloudlets to a broker, so that high-priority Cloudlets will be mapped to a VM first, or (ii) we could prioritize the execution of Cloudlets inside a VM.

Despite the Cloudlet class in CloudSim has a classType attribute that is intended to define priority, such an attribute is not used anywhere, so you don't have any kind of priority implemented.

If you need to define Cloudlets' execution priority, you can check CloudSim Plus, it's a full-featured, state-of-the-art, completely re-engineered and actively maintained CloudSim fork. Its CloudletSimple class has a priority attribute that is actually used by the CloudletSchedulerCompletelyFair. Such a scheduler is an implementation of the Completely Fair Linux Scheduler that considers a time slice/quantum to run Cloudlets and Cloudlet's priority.

Below is an sample snippet on how to use the mentioned scheduler and set priorities for Cloudlets:

vm.setCloudletScheduler(new CloudletSchedulerCompletelyFair());
for(int i=0; i < 10; i++){
    Cloudlet c = new CloudletSimple(CLOUDLET_LEN, CLOUDLET_PES);
    c.setPriority(i);  //you must define the priority in your own way
    cloudletList.add(c);
}

Check the full LinuxCompletelyFairSchedulerExample.

Manoel Campos
  • 933
  • 9
  • 12
  • Thank you for your kind response Sir. I was working on this issue "(i) we could prioritize the submission of Cloudlets to a broker, so that high-priority Cloudlets will be mapped to a VM first" . I did same by prioritizing cloudlet based on their budget offered by cloud customers. – Farwa Rajput Dec 10 '18 at 07:34
  • In such a case, you can use CloudSim Plus' DatacenterBrokerSimple class for that. That class enables you to change the current Round-Robin policy to allocate VMs to Cloudlets to a custom policy, without requiring you to change the code of the class or even create a new class. For instance, you just need to call `broker0.setVmMapper(this::bestFitCloudletToVmMapper);` and then define a method inside your simulation class as `private Vm bestFitCloudletToVmMapper(final Cloudlet cloudlet)`. Inside that method you implement your policy. – Manoel Campos Dec 10 '18 at 18:54
  • The method will be called every time a Cloudlet is requested to be placed inside a VM. You receive the Cloudlet as a parameter for the method and it must return the VM that you want to execute the Cloudlet. You can check a complete example at https://github.com/manoelcampos/cloudsim-plus/blob/master/cloudsim-plus-examples/src/main/java/org/cloudsimplus/examples/brokers/CloudletToVmMappingBestFit.java. Please upvote my first answer. Thank you. – Manoel Campos Dec 10 '18 at 18:56