Class ResourceProvisionerSimple
java.lang.Object
org.cloudbus.cloudsim.provisioners.ResourceProvisionerAbstract
org.cloudbus.cloudsim.provisioners.ResourceProvisionerSimple
- All Implemented Interfaces:
ResourceProvisioner
- Direct Known Subclasses:
PeProvisionerSimple
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
ModifierConstructorDescriptionCreates a new ResourceProvisionerSimple which theResourceManageable
it will manage have to be set further.protected
ResourceProvisionerSimple
(ResourceManageable resource, Function<Vm, ResourceManageable> vmResourceFunction) Creates a ResourceProvisionerSimple for a givenResourceManageable
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.long
Deallocate the resource for the given VM.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.boolean
isSuitableForVm
(Vm vm, Resource resource) 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
getAllocatedResourceForVm, getAvailableResource, getCapacity, getPmResource, getTotalAllocatedResource, getVmResourceFunction, setResources
-
Constructor Details
-
ResourceProvisionerSimple
public ResourceProvisionerSimple()Creates a new ResourceProvisionerSimple which theResourceManageable
it will manage have to be set further. -
ResourceProvisionerSimple
protected ResourceProvisionerSimple(ResourceManageable resource, Function<Vm, ResourceManageable> vmResourceFunction) Creates a ResourceProvisionerSimple for a givenResourceManageable
.- Parameters:
resource
- the resource to be managed by the provisionervmResourceFunction
- aFunction
that receives aVm
and returns the virtual resource corresponding to thePM resource
-
-
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 allocated 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:
-
deallocateResourceForVm
Description copied from interface:ResourceProvisioner
Deallocate the resource for the given VM.- 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 be allocated for the VM.- Returns:
- true, if it is possible to allocate the new total VM resource; false otherwise
-
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 VMresource
- the resource where its capacity it to be allocated for the VM.- Returns:
- true, if it is possible to allocate the new total VM resource; false otherwise
-