cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim/datacenters/DatacenterSimple.java
protected void processVmMigrate(final SimEvent ev, final boolean ack) {
        if (!(ev.getData() instanceof Map.Entry<?, ?>)) {
            throw new ClassCastException("The data object must be Map.Entry<Vm, Host>");
        }

        final Map.Entry<Vm, Host> entry = (Map.Entry<Vm, Host>) ev.getData();

        final Vm vm = entry.getKey();
        final Host targetHost = entry.getValue();

        vmAllocationPolicy.deallocateHostForVm(vm);
        targetHost.removeMigratingInVm(vm);
        final boolean result = vmAllocationPolicy.allocateHostForVm(vm, targetHost);

        if (ack) {
            sendNow(ev.getSource(), CloudSimTags.VM_CREATE_ACK, vm);
        }

        vm.setInMigration(false);
        if (result) {
            Log.printFormattedLine(
                "%.2f: Migration of VM #%d to Host #%d is completed",
                getSimulation().clock(), vm.getId(), targetHost.getId());
        } else {
            Log.printFormattedLine("[Datacenter] VM %d allocation to the destination host failed!", vm.getId());

        }
    }
/**
     * Process the event from the Datacenter to migrate a VM.
     *
     * @param ev information about the event just happened
     * @param ack indicates if the event's sender expects to receive an
     * acknowledge message when the event finishes to be processed
     *
     * @pre ev != null
     * @post $none
     */
Process the event from the Datacenter to migrate a VM.
@param ev information about the event just happened
@param ack indicates if the event's sender expects to receive an
acknowledge message when the event finishes to be processed

@pre ev != null
@post $none
Process the event from the Datacenter to migrate a VM . @param ev information about the event just happened @param ack indicates if the event ' s sender expects to receive an acknowledge message when the event finishes to be processed @pre ev ! = null @post $none
protected void processVmMigrate(final SimEvent ev, final boolean ack) {
        if (!(ev.getData() instanceof Map.Entry<?, ?>)) {
            throw new ClassCastException("The data object must be Map.Entry<Vm, Host>");
        }
        final Map.Entry<Vm, Host> entry = (Map.Entry<Vm, Host>) ev.getData();
        final Vm vm = entry.getKey();
        final Host targetHost = entry.getValue();
        vmAllocationPolicy.deallocateHostForVm(vm);
        targetHost.removeMigratingInVm(vm);
        final boolean result = vmAllocationPolicy.allocateHostForVm(vm, targetHost);
        if (ack) {
            sendNow(ev.getSource(), CloudSimTags.VM_CREATE_ACK, vm);
        }
        vm.setInMigration(false);
        if (result) {
            Log.printFormattedLine(
                "%.2f: Migration of VM #%d to Host #%d is completed",
                getSimulation().clock(), vm.getId(), targetHost.getId());
        } else {
            Log.printFormattedLine("[Datacenter] VM %d allocation to the destination host failed!", vm.getId());
        }
    }
protected void processVmMigrate ( final SimEvent ev , final boolean ack ) { if ( ! ( ev . getData ( ) instanceof Map . Entry < ? , ? > ) ) { throw new ClassCastException ( "The data object must be Map.Entry<Vm, Host>" ) ; } final Map . Entry < Vm , Host > entry = ( Map . Entry < Vm , Host > ) ev . getData ( ) ; final Vm vm = entry . getKey ( ) ; final Host targetHost = entry . getValue ( ) ; vmAllocationPolicy . deallocateHostForVm ( vm ) ; targetHost . removeMigratingInVm ( vm ) ; final boolean result = vmAllocationPolicy . allocateHostForVm ( vm , targetHost ) ; if ( ack ) { sendNow ( ev . getSource ( ) , CloudSimTags . VM_CREATE_ACK , vm ) ; } vm . setInMigration ( false ) ; if ( result ) { Log . printFormattedLine ( "%.2f: Migration of VM #%d to Host #%d is completed" , getSimulation ( ) . clock ( ) , vm . getId ( ) , targetHost . getId ( ) ) ; } else { Log . printFormattedLine ( "[Datacenter] VM %d allocation to the destination host failed!" , vm . getId ( ) ) ; } }
Process the event from the Datacenter to migrate a VM.
Process the event from the Datacenter to migrate a VM .