Interface ResourceProvisioner
- All Known Subinterfaces:
PeProvisioner
- All Known Implementing Classes:
PeProvisionerSimple
,ResourceProvisionerAbstract
,ResourceProvisionerSimple
public interface ResourceProvisioner
An interface that represents the provisioning policy used by a
Host
to provide a given physical resource to its Vm
s.
Each host must have its own instance of a ResourceProvisioner for each
Resource
it owns, such as Ram
, Bandwidth
(BW) and Pe
(CPU).- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
- To do something:
- There is a lot of confusion between Resource Allocation and Resource Provisioning. This article makes it clear: https://www.researchgate.net/post/what_is_the_difference_between_resource_allocation_and_resource_provisioning. Allocation is reservation, while Provisioning is actual usage of some part of the allocated resource. When a VM is created, the Host allocates resources, but the Host.allocateResourcesForVm uses ResourceProvisioners for that. More confusing yet, it calls vmScheduler.allocatePesForVm at the end. The terms allocation and provisioning sometimes are used in the same place. The Host.allocateResourcesForVm method has the word "allocate" in its name, while internally it uses ResourceProvisioners (quite confusing). VmScheduler is using the term "allocation", but since it's accountable for running a VM, it should perform resource provisioning (request the actual amount of the allocated resource to be used in that moment).
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ResourceProvisioner
An attribute that implements the Null Object Design Pattern for ResourceProvisioner objects. -
Method Summary
Modifier and TypeMethodDescriptiondefault 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.long
Deallocate the resource for the given VM.long
Gets the amount of resource allocated to a given VM from the physical resourcelong
Gets the amount of free available physical resource from the host that the provisioner can allocate to VMs.long
Gets the total capacity of the physical resource from the Host that the provisioner manages.long
Gets the total amount of resource allocated to all VMs from the physical resourceboolean
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.void
setResources
(ResourceManageable pmResource, Function<Vm, ResourceManageable> vmResourceFunction)
-
Field Details
-
NULL
An attribute that implements the Null Object Design Pattern for ResourceProvisioner objects.
-
-
Method Details
-
allocateResourceForVm
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
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:
-
getAllocatedResourceForVm
Gets the amount of resource allocated to a given VM from the physical resource- Parameters:
vm
- the VM- Returns:
- the allocated resource for the VM
-
getTotalAllocatedResource
long getTotalAllocatedResource()Gets the total amount of resource allocated to all VMs from the physical resource- Returns:
- the total allocated resource among all VMs
-
deallocateResourceForVm
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
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
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
-
getPmResource
ResourceManageable getPmResource()- Returns:
- the resource managed by this provisioner
-
setResources
void setResources(ResourceManageable pmResource, Function<Vm, ResourceManageable> vmResourceFunction) - Parameters:
pmResource
- the resource managed by this provisionervmResourceFunction
- aFunction
that receives aVm
and returns the virtual resource corresponding to thePM resource
-
getCapacity
long getCapacity()Gets the total capacity of the physical resource from the Host that the provisioner manages.- Returns:
- the total physical resource capacity
-
getAvailableResource
long getAvailableResource()Gets the amount of free available physical resource from the host that the provisioner can allocate to VMs.- Returns:
- the amount of free available physical resource
-