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 aHost
to provide a given physical resource to itsVm
s. Each host must have its own instance of a ResourceProvisioner for eachResource
it owns, such asRam
,Bandwidth
(BW) andPe
(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
Fields Modifier and Type Field Description static ResourceProvisioner
NULL
An attribute that implements the Null Object Design Pattern for ResourceProvisioner objects.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default 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.void
deallocateResourceForAllVms()
Releases all the allocated amount of the resource used by all VMs.boolean
deallocateResourceForVm(Vm vm)
Releases all the allocated amount of the resource used by a VM.long
getAllocatedResourceForVm(Vm vm)
Gets the amount of resource allocated to a given VM from the physical resourcelong
getAvailableResource()
Gets the amount of free available physical resource from the host that the provisioner can allocate to VMs.long
getCapacity()
Gets the total capacity of the physical resource from the Host that the provisioner manages.ResourceManageable
getResource()
long
getTotalAllocatedResource()
Gets the total amount of resource allocated to all VMs from the physical resourceboolean
isResourceAllocatedToVm(Vm vm)
Checks if the resource the provisioner manages is allocated to a 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.void
setResource(ResourceManageable resource)
-
-
-
Field Detail
-
NULL
static final ResourceProvisioner NULL
An attribute that implements the Null Object Design Pattern for ResourceProvisioner objects.
-
-
Method Detail
-
allocateResourceForVm
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.- 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
default 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.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:
allocateResourceForVm(Vm, long)
-
getAllocatedResourceForVm
long getAllocatedResourceForVm(Vm vm)
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
boolean deallocateResourceForVm(Vm vm)
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.
-
deallocateResourceForAllVms
void deallocateResourceForAllVms()
Releases all the allocated amount of the resource used by all VMs.
-
isSuitableForVm
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.- 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
-
getResource
ResourceManageable getResource()
- Returns:
- the resource managed by this provisioner
-
setResource
void setResource(ResourceManageable resource)
- Parameters:
resource
- the resource managed by this provisioner
-
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
-
isResourceAllocatedToVm
boolean isResourceAllocatedToVm(Vm vm)
Checks if the resource the provisioner manages is allocated to a given Vm.- Parameters:
vm
- the VM to check if the resource is allocated to- Returns:
- true if the resource is allocated to the VM, false otherwise
-
-