cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudsimplus/faultinjection/HostFaultInjection.java
private void cyclicallyRemoveFailedHostPesFromVms() {
        int failedPesToRemoveFromVms = numberOfFailedPesToRemoveFromVms();
        List<Vm> vmsWithPes = getVmsWithPEsFromFailedHost();
        final int affectedVms = Math.min(vmsWithPes.size(), failedPesToRemoveFromVms);

        Log.printFormattedLine("\t%d VMs affected from a total of %d. %d PEs are going to be removed from them.",
                affectedVms, lastFailedHost.getVmList().size(), failedPesToRemoveFromVms);
        int i = 0;
        while (!vmsWithPes.isEmpty() && failedPesToRemoveFromVms-- > 0) {
            i = i % vmsWithPes.size();
            Vm vm = vmsWithPes.get(i);
            lastFailedHost.getVmScheduler().deallocatePesFromVm(vm, 1);
            vm.getCloudletScheduler().deallocatePesFromVm(vm, 1);
            //remove 1 failed PE from the VM
            vm.getProcessor().deallocateAndRemoveResource(1);

            Log.printFormattedLine(
                    "\tRemoving 1 PE from VM %d due to Host PE failure. New VM PEs Number: %d\n",
                    vm.getId(), vm.getNumberOfPes());
            i++;
            vmsWithPes = getVmsWithPEsFromFailedHost();
        }
    }
/**
     * Removes one physical failed PE from one affected VM at a time.
     * Affected VMs are dealt as a circular list, visiting
     * one VM at a time to remove 1 PE from it,
     * until all the failed PEs are removed.
     *
     */
Removes one physical failed PE from one affected VM at a time.
Affected VMs are dealt as a circular list, visiting
one VM at a time to remove 1 PE from it,
until all the failed PEs are removed.
Removes one physical failed PE from one affected VM at a time . Affected VMs are dealt as a circular list visiting one VM at a time to remove 1 PE from it until all the failed PEs are removed .
private void cyclicallyRemoveFailedHostPesFromVms() {
        int failedPesToRemoveFromVms = numberOfFailedPesToRemoveFromVms();
        List<Vm> vmsWithPes = getVmsWithPEsFromFailedHost();
        final int affectedVms = Math.min(vmsWithPes.size(), failedPesToRemoveFromVms);
        Log.printFormattedLine("\t%d VMs affected from a total of %d. %d PEs are going to be removed from them.",
                affectedVms, lastFailedHost.getVmList().size(), failedPesToRemoveFromVms);
        int i = 0;
        while (!vmsWithPes.isEmpty() && failedPesToRemoveFromVms-- > 0) {
            i = i % vmsWithPes.size();
            Vm vm = vmsWithPes.get(i);
            lastFailedHost.getVmScheduler().deallocatePesFromVm(vm, 1);
            vm.getCloudletScheduler().deallocatePesFromVm(vm, 1);
            vm.getProcessor().deallocateAndRemoveResource(1);
            Log.printFormattedLine(
                    "\tRemoving 1 PE from VM %d due to Host PE failure. New VM PEs Number: %d\n",
                    vm.getId(), vm.getNumberOfPes());
            i++;
            vmsWithPes = getVmsWithPEsFromFailedHost();
        }
    }
private void cyclicallyRemoveFailedHostPesFromVms ( ) { int failedPesToRemoveFromVms = numberOfFailedPesToRemoveFromVms ( ) ; List < Vm > vmsWithPes = getVmsWithPEsFromFailedHost ( ) ; final int affectedVms = Math . min ( vmsWithPes . size ( ) , failedPesToRemoveFromVms ) ; Log . printFormattedLine ( "\t%d VMs affected from a total of %d. %d PEs are going to be removed from them." , affectedVms , lastFailedHost . getVmList ( ) . size ( ) , failedPesToRemoveFromVms ) ; int i = 0 ; while ( ! vmsWithPes . isEmpty ( ) && failedPesToRemoveFromVms -- > 0 ) { i = i % vmsWithPes . size ( ) ; Vm vm = vmsWithPes . get ( i ) ; lastFailedHost . getVmScheduler ( ) . deallocatePesFromVm ( vm , 1 ) ; vm . getCloudletScheduler ( ) . deallocatePesFromVm ( vm , 1 ) ; vm . getProcessor ( ) . deallocateAndRemoveResource ( 1 ) ; Log . printFormattedLine ( "\tRemoving 1 PE from VM %d due to Host PE failure. New VM PEs Number: %d\n" , vm . getId ( ) , vm . getNumberOfPes ( ) ) ; i ++ ; vmsWithPes = getVmsWithPEsFromFailedHost ( ) ; } }
Removes one physical failed PE from one affected VM at a time.
Removes one physical failed PE from one affected VM at a time .
//remove 1 failed PE from the VM