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 Vms.
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 TODO 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).
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ResourceProvisionerAn attribute that implements the Null Object Design Pattern for ResourceProvisioner objects. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanallocateResourceForVm(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.booleanallocateResourceForVm(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.longDeallocate the resource for the given VM.longGets the amount of resource allocated to a given VM from the physical resourcelongGets the amount of free available physical resource from the Host that the provisioner can allocate to VMs.longGets the total capacity of the physical resource from the Host that the provisioner manages.longbooleanisSuitableForVm(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.booleanisSuitableForVm(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.voidsetResources(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 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 amount.- Returns:
trueif the resource could be allocated;falseotherwise
-
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 amount- Returns:
trueif the resource could be allocated;falseotherwise- 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()- Returns:
- the total amount of resource allocated to all VMs from the physical resource.
-
deallocateResourceForVm
Deallocate the resource for the given VM.- Parameters:
vm- the VM to deallocate the 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 capacity 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 capacity 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- aFunctionthat receives aVmand 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
-