Gokul M Gokul M - 2 years ago 104
Java Question

Cloudsim: Update VM

I am working on an algorithm to select the

for deploying the
Now, I need to update the VM's current allocated ram whenever a cloudlet finished it's execution.

I don't know where I need to do this.

I tried this in
method in

but it is called only after all cloudlets are submitted to the VMs.

I need to update the VM's Ram whenever a cloudlet executed successfully.

For, ex:

Let us consider, I have 100 tasks to be deployed and now I submitted 20 tasks then, before submitting 21st task if 1st task finishes its execution I need to update the corresponding VM.

Can anyone help me..
Thank you..

Answer Source

You can do as below:

for(Cloudlet cloudlet: getCloudletSubmittedList()){
        if(!finishedCloudlets.contains(cloudlet) && cloudlet.isFinished()){
        Vm vm = getVmsCreatedList().get(cloudlet.getVmId()-1);                        
        vm.setCurrentAllocatedRam(vm.getCurrentAllocatedRam() - (int)(cloudlet.getUtilizationOfRam(CloudSim.clock())*100));
        vm.updateVmProcessing(CloudSim.clock(), null);

where you can check whether already submitted tasks are finished if so you can update your VM.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download