Class ResourceProvisionerSimple
java.lang.Object
org.cloudbus.cloudsim.provisioners.ResourceProvisionerAbstract
org.cloudbus.cloudsim.provisioners.ResourceProvisionerSimple
- All Implemented Interfaces:
ResourceProvisioner
- Direct Known Subclasses:
PeProvisionerSimple
public class ResourceProvisionerSimple extends ResourceProvisionerAbstract
A best-effort
ResourceProvisioner
policy used by a Host
to provide a resource to VMs:
- if there is available amount of the resource on the host, it provides;
- otherwise, it fails.
- Since:
- 3.0.4
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.provisioners.ResourceProvisioner
NULL
-
Constructor Summary
Constructors Modifier Constructor Description ResourceProvisionerSimple()
Creates a new ResourceProvisionerSimple which theResourceManageable
it will manage have to be set further.protected
ResourceProvisionerSimple(ResourceManageable resource)
Creates a ResourceProvisionerSimple for a givenResourceManageable
. -
Method Summary
Modifier and Type Method Description boolean
allocateResourceForVm(Vm vm, double newTotalVmResource)
Allocates an amount of the physical resource for a VM, changing the current capacity of the virtual resource to the given amount.boolean
allocateResourceForVm(Vm vm, long newTotalVmResourceCapacity)
Allocates an amount of the physical resource for a VM, changing the current capacity of the virtual resource to the given amount.boolean
deallocateResourceForVm(Vm vm)
Releases all the allocated amount of the resource used by a VM.protected long
deallocateResourceForVmAndSetAllocationMapEntryToZero(Vm vm)
Deallocate the resource for the given VM, without removing the VM fro the allocation map.boolean
isSuitableForVm(Vm vm, long newVmTotalAllocatedResource)
Checks if it is possible to change the current allocated resource for a given VM to a new amount, depending on the available physical resource remaining.Methods inherited from class org.cloudbus.cloudsim.provisioners.ResourceProvisionerAbstract
deallocateResourceForAllVms, getAllocatedResourceForVm, getAvailableResource, getCapacity, getResource, getResourceAllocationMap, getResourceClass, getTotalAllocatedResource, isResourceAllocatedToVm, setResource
-
Constructor Details
-
ResourceProvisionerSimple
public ResourceProvisionerSimple()Creates a new ResourceProvisionerSimple which theResourceManageable
it will manage have to be set further. -
ResourceProvisionerSimple
Creates a ResourceProvisionerSimple for a givenResourceManageable
.- Parameters:
resource
- the resource to be managed by the provisioner
-
-
Method Details
-
allocateResourceForVm
Description copied from interface:ResourceProvisioner
Allocates an amount of the physical resource for a VM, changing the current capacity of the virtual resource to the given amount.- Parameters:
vm
- the virtual machine for which the resource is being allocatednewTotalVmResourceCapacity
- the new total amount of resource to allocate to the VM, changing the allocate resource to this new amount. It doesn't increase the current allocated VM resource by the given amount, instead, it changes the VM allocated resource to that specific amount- Returns:
- $true if the resource could be allocated; $false otherwise
-
allocateResourceForVm
Description copied from interface:ResourceProvisioner
Allocates an amount of the physical resource for a VM, changing the current capacity of the virtual resource to the given amount.This method is just a shorthand to avoid explicitly converting a double to long.
- Parameters:
vm
- the virtual machine for which the resource is being allocatednewTotalVmResource
- the new total amount of resource to allocate to the VM, changing the allocate resource to this new amount. It doesn't increase the current allocated VM resource by the given amount, instead, it changes the VM allocated resource to that specific amount- Returns:
- $true if the resource could be allocated; $false otherwise
- See Also:
ResourceProvisioner.allocateResourceForVm(Vm, long)
-
deallocateResourceForVm
Description copied from interface:ResourceProvisioner
Releases all the allocated amount of the resource used by a VM.- Parameters:
vm
- the vm- Returns:
- true if the resource was deallocated; false if the related resource has never been allocated to the given VM.
-
deallocateResourceForVmAndSetAllocationMapEntryToZero
Description copied from class:ResourceProvisionerAbstract
Deallocate the resource for the given VM, without removing the VM fro the allocation map. The resource usage of the VM entry on the allocation map is just set to 0.- Specified by:
deallocateResourceForVmAndSetAllocationMapEntryToZero
in classResourceProvisionerAbstract
- Parameters:
vm
- the VM to deallocate resource- Returns:
- the amount of allocated VM resource or zero if VM is not found
-
isSuitableForVm
Description copied from interface:ResourceProvisioner
Checks if it is possible to change the current allocated resource for a given VM to a new amount, depending on the available physical resource remaining.- Parameters:
vm
- the vm to check if there is enough available resource on the host to change the allocated amount for the VMnewVmTotalAllocatedResource
- the new total amount of resource to allocate for the VM.- Returns:
- true, if it is possible to allocate the new total VM resource; false otherwise
-