cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudsimplus/faultinjection/HostFaultInjection.java
private void generateHostFault() {
        try {
            final Host failedHost = getRandomHost();
            if(Host.NULL == failedHost || failedHost.getVmList().isEmpty()){
                return;
            }

            this.lastFailedHost = failedHost;
            if (Host.NULL.equals(lastFailedHost)) {
                return;
            }

            numberOfHostFaults++;
            registerHostFaultTime();

            final long previousNumOfWorkingPes = lastFailedHost.getNumberOfWorkingPes();
            this.lastNumberOfFailedPes = generateHostPesFaults();
            final long hostWorkingPes = lastFailedHost.getNumberOfWorkingPes();
            final long vmsRequiredPes = getPesSumOfWorkingVms();

            Log.printFormattedLine("%.2f: %s: Generated %d PEs failures from %d previously working PEs for %s at minute %.2f",
                    getSimulation().clock(), getClass().getSimpleName(),
                lastNumberOfFailedPes, previousNumOfWorkingPes, lastFailedHost, getSimulation().clock() / 60);
            Log.printFormattedLine("\tCurrent Working PEs: %d | Number of VMs: %d", hostWorkingPes, lastFailedHost.getVmList().size());
            if(!lastFailedHost.getVmList().isEmpty()) {
                Log.printFormattedLine("\tVMs required PEs: %d", vmsRequiredPes);
            }

            if (hostWorkingPes == 0) {
                setAllVmsToFailed();
            } else if (hostWorkingPes >= vmsRequiredPes) {
                logNoVmFault();
            } else {
                deallocateFailedHostPesFromVms();
            }
        } finally {
            //schedules the next failure injection
            scheduleFaultInjection();
        }
    }
/**
     * Generates a failure for a specific number of PEs from a
     * randomly selected Host.
     */
Generates a failure for a specific number of PEs from a
randomly selected Host.
Generates a failure for a specific number of PEs from a randomly selected Host .
private void generateHostFault() {
        try {
            final Host failedHost = getRandomHost();
            if(Host.NULL == failedHost || failedHost.getVmList().isEmpty()){
                return;
            }
            this.lastFailedHost = failedHost;
            if (Host.NULL.equals(lastFailedHost)) {
                return;
            }
            numberOfHostFaults++;
            registerHostFaultTime();
            final long previousNumOfWorkingPes = lastFailedHost.getNumberOfWorkingPes();
            this.lastNumberOfFailedPes = generateHostPesFaults();
            final long hostWorkingPes = lastFailedHost.getNumberOfWorkingPes();
            final long vmsRequiredPes = getPesSumOfWorkingVms();
            Log.printFormattedLine("%.2f: %s: Generated %d PEs failures from %d previously working PEs for %s at minute %.2f",
                    getSimulation().clock(), getClass().getSimpleName(),
                lastNumberOfFailedPes, previousNumOfWorkingPes, lastFailedHost, getSimulation().clock() / 60);
            Log.printFormattedLine("\tCurrent Working PEs: %d | Number of VMs: %d", hostWorkingPes, lastFailedHost.getVmList().size());
            if(!lastFailedHost.getVmList().isEmpty()) {
                Log.printFormattedLine("\tVMs required PEs: %d", vmsRequiredPes);
            }
            if (hostWorkingPes == 0) {
                setAllVmsToFailed();
            } else if (hostWorkingPes >= vmsRequiredPes) {
                logNoVmFault();
            } else {
                deallocateFailedHostPesFromVms();
            }
        } finally {
            scheduleFaultInjection();
        }
    }
private void generateHostFault ( ) { try { final Host failedHost = getRandomHost ( ) ; if ( Host . NULL == failedHost || failedHost . getVmList ( ) . isEmpty ( ) ) { return ; } this . lastFailedHost = failedHost ; if ( Host . NULL . equals ( lastFailedHost ) ) { return ; } numberOfHostFaults ++ ; registerHostFaultTime ( ) ; final long previousNumOfWorkingPes = lastFailedHost . getNumberOfWorkingPes ( ) ; this . lastNumberOfFailedPes = generateHostPesFaults ( ) ; final long hostWorkingPes = lastFailedHost . getNumberOfWorkingPes ( ) ; final long vmsRequiredPes = getPesSumOfWorkingVms ( ) ; Log . printFormattedLine ( "%.2f: %s: Generated %d PEs failures from %d previously working PEs for %s at minute %.2f" , getSimulation ( ) . clock ( ) , getClass ( ) . getSimpleName ( ) , lastNumberOfFailedPes , previousNumOfWorkingPes , lastFailedHost , getSimulation ( ) . clock ( ) / 60 ) ; Log . printFormattedLine ( "\tCurrent Working PEs: %d | Number of VMs: %d" , hostWorkingPes , lastFailedHost . getVmList ( ) . size ( ) ) ; if ( ! lastFailedHost . getVmList ( ) . isEmpty ( ) ) { Log . printFormattedLine ( "\tVMs required PEs: %d" , vmsRequiredPes ) ; } if ( hostWorkingPes == 0 ) { setAllVmsToFailed ( ) ; } else if ( hostWorkingPes >= vmsRequiredPes ) { logNoVmFault ( ) ; } else { deallocateFailedHostPesFromVms ( ) ; } } finally { scheduleFaultInjection ( ) ; } }
Generates a failure for a specific number of PEs from a
 randomly selected Host.
Generates a failure for a specific number of PEs from a randomly selected Host .
//schedules the next failure injection