How to Migrate the Cloudlet from one VM to another VM

  • The task/cloudlet migration can be done in “Datacenter” class, “Cloudlet Scheduler” class. Here, in “Datacentcenter” class, in “processCloudletSubmit()” method, a cloudlet is chosen with its id as a checking condition and its VM id is collected and the CLOUDLET_MOVE event is triggered.
  • protected void processCloudletSubmit(SimEvent ev, boolean ack) {
    ……;
    ……;
    Cloudlet cl = (Cloudlet) ev.getData();
    ……;
    ……;
    cl.setResourceParameter(getId(),getCharacteristics().getCostPerSecond(), getCharacteristics().getCostPerBw());
    int userId = cl.getUserId();
    int vmId = cl.getVmId();
    if(cl.getCloudletId()==3){ // the cloudlet which has id 3 is chosen
    arr[0] = cl.getCloudletId(); //cloudlet id which is going to migrate
    arr[1] = cl.getUserId(); // migrating cloudlet's userid
    arr[2] = cl.getVmId(); //migrating cloudlet's VM id
    arr[3] = 4; //migrating cloudlet's new VM id
    arr[4] = getId(); //datacenter idsendNow(getId(), CloudSimTags.CLOUDLET_MOVE, arr); // the Move event is triggered.
    }
    ………;
    ………;
    }