cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim/allocationpolicies/VmAllocationPolicyAbstract.java
private boolean downScaleVmNonCpuResource(VerticalVmScaling scaling) {
        final Class<? extends ResourceManageable> resourceClass = scaling.getResourceClass();
        final ResourceManageable vmResource = scaling.getVm().getResource(resourceClass);
        final double amountToDeallocate = scaling.getResourceAmountToScale();
        final ResourceProvisioner provisioner = scaling.getVm().getHost().getProvisioner(resourceClass);
        final double newTotalVmResource = vmResource.getCapacity() - amountToDeallocate;
        if(!provisioner.allocateResourceForVm(scaling.getVm(), newTotalVmResource)){
            Log.printFormattedLine(
                "%.2f: %s: Vm %d requested to reduce %s capacity by %d but an unexpected error occurred and the resource was not resized",
                scaling.getVm().getSimulation().clock(),
                scaling.getClass().getSimpleName(),
                scaling.getVm().getId(),
                resourceClass.getSimpleName(), amountToDeallocate);
            return false;
        }

        Log.printFormattedLine(
            "%.2f: %s: %d %s deallocated from Vm %d: new capacity is %d. Current resource usage is %.2f%%",
            scaling.getVm().getSimulation().clock(),
            scaling.getClass().getSimpleName(),
            amountToDeallocate, resourceClass.getSimpleName(),
            scaling.getVm().getId(), vmResource.getCapacity(),
            vmResource.getPercentUtilization()*100);
        return true;
    }
/**
     * Performs the down scaling of a Vm resource that is anything other than CPU.
     *
     * @param scaling the Vm's scaling object
     * @return true if the down scaling was performed, false otherwise
     * @see #downScaleVmVertically(VerticalVmScaling)
     */
Performs the down scaling of a Vm resource that is anything other than CPU.
@param scaling the Vm's scaling object
@return true if the down scaling was performed, false otherwise
@see #downScaleVmVertically(VerticalVmScaling)
Performs the down scaling of a Vm resource that is anything other than CPU . @param scaling the Vm ' s scaling object @return true if the down scaling was performed false otherwise @see #downScaleVmVertically ( VerticalVmScaling )
private boolean downScaleVmNonCpuResource(VerticalVmScaling scaling) {
        final Class<? extends ResourceManageable> resourceClass = scaling.getResourceClass();
        final ResourceManageable vmResource = scaling.getVm().getResource(resourceClass);
        final double amountToDeallocate = scaling.getResourceAmountToScale();
        final ResourceProvisioner provisioner = scaling.getVm().getHost().getProvisioner(resourceClass);
        final double newTotalVmResource = vmResource.getCapacity() - amountToDeallocate;
        if(!provisioner.allocateResourceForVm(scaling.getVm(), newTotalVmResource)){
            Log.printFormattedLine(
                "%.2f: %s: Vm %d requested to reduce %s capacity by %d but an unexpected error occurred and the resource was not resized",
                scaling.getVm().getSimulation().clock(),
                scaling.getClass().getSimpleName(),
                scaling.getVm().getId(),
                resourceClass.getSimpleName(), amountToDeallocate);
            return false;
        }
        Log.printFormattedLine(
            "%.2f: %s: %d %s deallocated from Vm %d: new capacity is %d. Current resource usage is %.2f%%",
            scaling.getVm().getSimulation().clock(),
            scaling.getClass().getSimpleName(),
            amountToDeallocate, resourceClass.getSimpleName(),
            scaling.getVm().getId(), vmResource.getCapacity(),
            vmResource.getPercentUtilization()*100);
        return true;
    }
private boolean downScaleVmNonCpuResource ( VerticalVmScaling scaling ) { final Class < ? extends ResourceManageable > resourceClass = scaling . getResourceClass ( ) ; final ResourceManageable vmResource = scaling . getVm ( ) . getResource ( resourceClass ) ; final double amountToDeallocate = scaling . getResourceAmountToScale ( ) ; final ResourceProvisioner provisioner = scaling . getVm ( ) . getHost ( ) . getProvisioner ( resourceClass ) ; final double newTotalVmResource = vmResource . getCapacity ( ) - amountToDeallocate ; if ( ! provisioner . allocateResourceForVm ( scaling . getVm ( ) , newTotalVmResource ) ) { Log . printFormattedLine ( "%.2f: %s: Vm %d requested to reduce %s capacity by %d but an unexpected error occurred and the resource was not resized" , scaling . getVm ( ) . getSimulation ( ) . clock ( ) , scaling . getClass ( ) . getSimpleName ( ) , scaling . getVm ( ) . getId ( ) , resourceClass . getSimpleName ( ) , amountToDeallocate ) ; return false ; } Log . printFormattedLine ( "%.2f: %s: %d %s deallocated from Vm %d: new capacity is %d. Current resource usage is %.2f%%" , scaling . getVm ( ) . getSimulation ( ) . clock ( ) , scaling . getClass ( ) . getSimpleName ( ) , amountToDeallocate , resourceClass . getSimpleName ( ) , scaling . getVm ( ) . getId ( ) , vmResource . getCapacity ( ) , vmResource . getPercentUtilization ( ) * 100 ) ; return true ; }
Performs the down scaling of a Vm resource that is anything other than CPU.
Performs the down scaling of a Vm resource that is anything other than CPU .