Wednesday, June 17, 2015

Cloudsim: allocating vm's to hosts and running cloudlets with different start times

So I was trying to create my own broker policies....

Bind VM's to particular hosts

First up, i needed to manually allocate VM's to particular hosts so they have different MIPS.

This was done successfully.

I did an override on the allocateHostForVm(Vm vm) method.
Then I wrote some code like
 if(vmid == 0){
        Host host = this.getHostList().get(0);
        vm_allocated = this.allocateHostForVm(vm, host);      
}
if(vmid == 1){
        Host host = this.getHostList().get(1);
         vm_allocated = this.allocateHostForVm(vm, host);      
}
so on 'n so forth.... to allocate all the vm's to my hosts....
I needed to do this because I created VM's with different Mips 'n it was not getting allocated to the host that has that capacity...

Then for varying the submit time of the cloudlet I have extended the cloudlet to MyCloudlet and added a different submission time for the cloudlet.

super(cloudletId, cloudletLength, pesNumber, cloudletFileSize,
cloudletOutputSize, utilizationModelCpu, utilizationModelRam,
utilizationModelBw);
// TODO Auto-generated constructor stub
this.startTime = startTime;
                this.setStartTime(startTime);
                this.setSubmissionTime(startTime);
                Log.printLine("Start time cloudlet "+cloudletId+"startTime :"+this.getSubmissionTime());

There seems to be a problem....
For a long time, my cloudlets were getting submitted at the proper time... but now for no sane reason... the submission time of the cloudlets are how I set it... but then all the cloudlets start at time 0 or whenever the vm's get created!

Did some pokin' around, then found this.... After I've set submission time to user defined submission time... when I used getSubmissionTime(), I still get


Start time cloudlet 7startTime :0.0
Start time cloudlet 8startTime :0.0
Start time cloudlet 9startTime :0.0


When I changed this.setStarTime(startTime) to this.setStartTime(this.startTime)... The getStartTime() was giving the correct output... but submission time was still getting set to 0.

wow... so, I had to go back to my own notes to solve this...
I think when i made some other changes in the mydatacenterBroker code... I accidentally changed the submitcloudlets method also...
I'll put up the entire code with all the changes so this does not happen again!!!
Can't believe I was again stuck with this for this long :(

Simulated cloudlets with varying Submission Times


protected void submitCloudlets() {
                int vmIndex = 0;
                List<MyCloudlet> successfullySubmitted = new ArrayList<MyCloudlet>();
                for (Cloudlet cloudlet : getCloudletList()) {
                   
                    // typecast cloudlet to user defined mycloudlet
                    MyCloudlet myCloudlet = (MyCloudlet)cloudlet;
                        Vm vm;
                        // if user didn't bind this cloudlet and it has not been executed yet
                        if (myCloudlet.getVmId() == -1) {
                                vm = getVmsCreatedList().get(vmIndex);
                        } else { // submit to the specific vm
                                vm = VmList.getById(getVmsCreatedList(), myCloudlet.getVmId());
                                if (vm == null) { // vm was not created
                                        Log.printLine(CloudSim.clock() + ": " + getName() + ": Postponing execution of cloudlet "
                                                        + myCloudlet.getCloudletId() + ": bount VM not available");
                                        continue;
                                }
                        }

                        Log.printLine(CloudSim.clock() + ": " + getName() + ": Sending cloudlet "
                                        + myCloudlet.getCloudletId() + " to VM #" + vm.getId());
                        myCloudlet.setVmId(vm.getId());
                        send(getVmsToDatacentersMap().get(vm.getId()),myCloudlet.getStartTime(), CloudSimTags.CLOUDLET_SUBMIT, myCloudlet);
                       
                        //sendNow(getVmsToDatacentersMap().get(vm.getId()), CloudSimTags.CLOUDLET_SUBMIT, cloudlet);
                        cloudletsSubmitted++;
                        vmIndex = (vmIndex + 1) % getVmsCreatedList().size();
                        getCloudletSubmittedList().add(myCloudlet);
                        successfullySubmitted.add(myCloudlet);
                }

                // remove submitted cloudlets from waiting list
                getCloudletList().removeAll(successfullySubmitted);
        }


So basically, change all the cloudlet to mycloudlet which i typecasted from cloudlet...


'n we're back in business now :)





2 comments: