ResourceProvisioner

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).

Author:Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho

Fields

NULL

ResourceProvisioner NULL

An attribute that implements the Null Object Design Pattern for ResourceProvisioner objects.

Methods

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 allocated
  • newTotalVmResourceCapacity – 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

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 allocated
  • newTotalVmResource – 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)

deallocateResourceForAllVms

void deallocateResourceForAllVms()

Releases all the allocated amount of the resource used by 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.

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

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

getCapacity

long getCapacity()

Gets the total capacity of the physical resource from the Host that the provisioner manages.

Returns:the total physical resource capacity

getResource

ResourceManageable getResource()

Gets the resource being managed by the provisioner, such as Ram, Pe, Bandwidth, etc.

Returns:the resource managed by this provisioner

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

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

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 VM
  • newVmTotalAllocatedResource – 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

setResource

void setResource(ResourceManageable resource)

Sets the resource to be managed by the provisioner, such as Ram, Pe, Bandwidth, etc.

Parameters:
  • resource – the resource managed by this provisioner