cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim/hosts/HostSimple.java
private boolean allocateResourcesForVm(Vm vm, boolean inMigration){
        final String msg = inMigration ? "VM Migration" : "VM Creation";
        if (!storage.isResourceAmountAvailable(vm.getStorage())) {
            Log.printFormattedLine(
                "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of storage. Required %d but there is just %d MB available.",
                simulation.clock(), getClass().getSimpleName(),
                msg, vm, this, vm.getStorage().getCapacity(), storage.getAvailableResource());
            return false;
        }

        if (!ramProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedRam())) {
            Log.printFormattedLine(
                "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of RAM. Required %d but there is just %d MB available.",
                simulation.clock(), getClass().getSimpleName(),
                msg, vm, this, vm.getRam().getCapacity(), ram.getAvailableResource());
            return false;
        }

        if (!bwProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedBw())) {
            Log.printFormattedLine(
                "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of BW. Required %d but there is just %d Mbps available.",
                simulation.clock(), getClass().getSimpleName(),
                msg, vm, this, vm.getBw().getCapacity(), bw.getAvailableResource());
            return false;
        }

        if (!vmScheduler.isSuitableForVm(vm)) {
            Log.printFormattedLine(
                    "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of PEs.\n\t  "+
                    "Required %d PEs of %.0f MIPS (%.0f MIPS total). However, there are just %d working PEs of %.0f MIPS, from which %.0f MIPS are available.",
                    getSimulation().clock(), getClass().getSimpleName(), msg, vm, this,
                    vm.getNumberOfPes(), vm.getMips(), vm.getTotalMipsCapacity(),
                    vmScheduler.getWorkingPeList().size(), getMips(), vmScheduler.getAvailableMips());
            return false;
        }

        vm.setInMigration(inMigration);
        storage.allocateResource(vm.getStorage());
        ramProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedRam());
        bwProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedBw());
        vmScheduler.allocatePesForVm(vm, vm.getCurrentRequestedMips());

        return true;
    }
/**
     * Try to allocate all resources that a VM requires (Storage, RAM, BW and MIPS) to be placed at this Host.
     *
     * @param vm the VM to try allocating resources to
     * @param inMigration If the VM is migrating into the Host or it is being just created for the first time
     * @return true if the Vm was placed into the host, false if the Host doesn't have enough resources to allocate the Vm
     */
Try to allocate all resources that a VM requires (Storage, RAM, BW and MIPS) to be placed at this Host.
@param vm the VM to try allocating resources to
@param inMigration If the VM is migrating into the Host or it is being just created for the first time
@return true if the Vm was placed into the host, false if the Host doesn't have enough resources to allocate the Vm
Try to allocate all resources that a VM requires ( Storage RAM BW and MIPS ) to be placed at this Host . @param vm the VM to try allocating resources to @param inMigration If the VM is migrating into the Host or it is being just created for the first time @return true if the Vm was placed into the host false if the Host doesn ' t have enough resources to allocate the Vm
private boolean allocateResourcesForVm(Vm vm, boolean inMigration){
        final String msg = inMigration ? "VM Migration" : "VM Creation";
        if (!storage.isResourceAmountAvailable(vm.getStorage())) {
            Log.printFormattedLine(
                "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of storage. Required %d but there is just %d MB available.",
                simulation.clock(), getClass().getSimpleName(),
                msg, vm, this, vm.getStorage().getCapacity(), storage.getAvailableResource());
            return false;
        }
        if (!ramProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedRam())) {
            Log.printFormattedLine(
                "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of RAM. Required %d but there is just %d MB available.",
                simulation.clock(), getClass().getSimpleName(),
                msg, vm, this, vm.getRam().getCapacity(), ram.getAvailableResource());
            return false;
        }
        if (!bwProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedBw())) {
            Log.printFormattedLine(
                "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of BW. Required %d but there is just %d Mbps available.",
                simulation.clock(), getClass().getSimpleName(),
                msg, vm, this, vm.getBw().getCapacity(), bw.getAvailableResource());
            return false;
        }
        if (!vmScheduler.isSuitableForVm(vm)) {
            Log.printFormattedLine(
                    "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of PEs.\n\t  "+
                    "Required %d PEs of %.0f MIPS (%.0f MIPS total). However, there are just %d working PEs of %.0f MIPS, from which %.0f MIPS are available.",
                    getSimulation().clock(), getClass().getSimpleName(), msg, vm, this,
                    vm.getNumberOfPes(), vm.getMips(), vm.getTotalMipsCapacity(),
                    vmScheduler.getWorkingPeList().size(), getMips(), vmScheduler.getAvailableMips());
            return false;
        }
        vm.setInMigration(inMigration);
        storage.allocateResource(vm.getStorage());
        ramProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedRam());
        bwProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedBw());
        vmScheduler.allocatePesForVm(vm, vm.getCurrentRequestedMips());
        return true;
    }
private boolean allocateResourcesForVm ( Vm vm , boolean inMigration ) { final String msg = inMigration ? "VM Migration" : "VM Creation" ; if ( ! storage . isResourceAmountAvailable ( vm . getStorage ( ) ) ) { Log . printFormattedLine ( "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of storage. Required %d but there is just %d MB available." , simulation . clock ( ) , getClass ( ) . getSimpleName ( ) , msg , vm , this , vm . getStorage ( ) . getCapacity ( ) , storage . getAvailableResource ( ) ) ; return false ; } if ( ! ramProvisioner . isSuitableForVm ( vm , vm . getCurrentRequestedRam ( ) ) ) { Log . printFormattedLine ( "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of RAM. Required %d but there is just %d MB available." , simulation . clock ( ) , getClass ( ) . getSimpleName ( ) , msg , vm , this , vm . getRam ( ) . getCapacity ( ) , ram . getAvailableResource ( ) ) ; return false ; } if ( ! bwProvisioner . isSuitableForVm ( vm , vm . getCurrentRequestedBw ( ) ) ) { Log . printFormattedLine ( "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of BW. Required %d but there is just %d Mbps available." , simulation . clock ( ) , getClass ( ) . getSimpleName ( ) , msg , vm , this , vm . getBw ( ) . getCapacity ( ) , bw . getAvailableResource ( ) ) ; return false ; } if ( ! vmScheduler . isSuitableForVm ( vm ) ) { Log . printFormattedLine ( "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of PEs.\n\t  " + "Required %d PEs of %.0f MIPS (%.0f MIPS total). However, there are just %d working PEs of %.0f MIPS, from which %.0f MIPS are available." , getSimulation ( ) . clock ( ) , getClass ( ) . getSimpleName ( ) , msg , vm , this , vm . getNumberOfPes ( ) , vm . getMips ( ) , vm . getTotalMipsCapacity ( ) , vmScheduler . getWorkingPeList ( ) . size ( ) , getMips ( ) , vmScheduler . getAvailableMips ( ) ) ; return false ; } vm . setInMigration ( inMigration ) ; storage . allocateResource ( vm . getStorage ( ) ) ; ramProvisioner . allocateResourceForVm ( vm , vm . getCurrentRequestedRam ( ) ) ; bwProvisioner . allocateResourceForVm ( vm , vm . getCurrentRequestedBw ( ) ) ; vmScheduler . allocatePesForVm ( vm , vm . getCurrentRequestedMips ( ) ) ; return true ; }
Try to allocate all resources that a VM requires (Storage, RAM, BW and MIPS) to be placed at this Host.
Try to allocate all resources that a VM requires ( Storage RAM BW and MIPS ) to be placed at this Host .