Class ResourceProvisionerAbstract
java.lang.Object
org.cloudbus.cloudsim.provisioners.ResourceProvisionerAbstract
- All Implemented Interfaces:
ResourceProvisioner
- Direct Known Subclasses:
ResourceProvisionerSimple
public abstract class ResourceProvisionerAbstract extends Object implements ResourceProvisioner
An abstract class that implements the basic features of a provisioning policy used by a
Host
to provide a given resource to its virtual machines.- Since:
- 3.0.4
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
- See Also:
ResourceProvisioner
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.provisioners.ResourceProvisioner
NULL
-
Constructor Summary
Constructors Modifier Constructor Description protected
ResourceProvisionerAbstract()
Creates a new ResourceManageable Provisioner for which theresource
must be set further.ResourceProvisionerAbstract(ResourceManageable resource)
Creates a new ResourceManageable Provisioner. -
Method Summary
Modifier and Type Method Description void
deallocateResourceForAllVms()
Releases all the allocated amount of the resource used by all VMs.protected abstract long
deallocateResourceForVmAndSetAllocationMapEntryToZero(Vm vm)
Deallocate the resource for the given VM, without removing the VM fro the allocation map.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()
protected Map<Vm,Long>
getResourceAllocationMap()
Gets the VM resource allocation map, where each key is a VM and each value is the amount of resource allocated to that VM.protected Class<? extends ResourceManageable>
getResourceClass()
Gets the class of the resource that this provisioner manages.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.void
setResource(ResourceManageable resource)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cloudbus.cloudsim.provisioners.ResourceProvisioner
allocateResourceForVm, allocateResourceForVm, deallocateResourceForVm, isSuitableForVm
-
Constructor Details
-
ResourceProvisionerAbstract
protected ResourceProvisionerAbstract()Creates a new ResourceManageable Provisioner for which theresource
must be set further. -
ResourceProvisionerAbstract
Creates a new ResourceManageable Provisioner.- Parameters:
resource
- The resource to be managed by the provisioner
-
-
Method Details
-
getAllocatedResourceForVm
Description copied from interface:ResourceProvisioner
Gets the amount of resource allocated to a given VM from the physical resource- Specified by:
getAllocatedResourceForVm
in interfaceResourceProvisioner
- Parameters:
vm
- the VM- Returns:
- the allocated resource for the VM
-
deallocateResourceForAllVms
public void deallocateResourceForAllVms()Description copied from interface:ResourceProvisioner
Releases all the allocated amount of the resource used by all VMs.- Specified by:
deallocateResourceForAllVms
in interfaceResourceProvisioner
-
deallocateResourceForVmAndSetAllocationMapEntryToZero
Deallocate the resource for the given VM, without removing the VM fro the allocation map. The resource usage of the VM entry on the allocation map is just set to 0.- Parameters:
vm
- the VM to deallocate resource- Returns:
- the amount of allocated VM resource or zero if VM is not found
-
getResource
Description copied from interface:ResourceProvisioner
- Specified by:
getResource
in interfaceResourceProvisioner
- Returns:
- the resource managed by this provisioner
-
setResource
Description copied from interface:ResourceProvisioner
- Specified by:
setResource
in interfaceResourceProvisioner
- Parameters:
resource
- the resource managed by this provisioner
-
getResourceClass
Gets the class of the resource that this provisioner manages.- Returns:
- the resource class
-
getResourceAllocationMap
Gets the VM resource allocation map, where each key is a VM and each value is the amount of resource allocated to that VM.- Returns:
- the resource allocation Map
-
getCapacity
public long getCapacity()Description copied from interface:ResourceProvisioner
Gets the total capacity of the physical resource from the Host that the provisioner manages.- Specified by:
getCapacity
in interfaceResourceProvisioner
- Returns:
- the total physical resource capacity
-
getTotalAllocatedResource
public long getTotalAllocatedResource()Description copied from interface:ResourceProvisioner
Gets the total amount of resource allocated to all VMs from the physical resource- Specified by:
getTotalAllocatedResource
in interfaceResourceProvisioner
- Returns:
- the total allocated resource among all VMs
-
getAvailableResource
public long getAvailableResource()Description copied from interface:ResourceProvisioner
Gets the amount of free available physical resource from the host that the provisioner can allocate to VMs.- Specified by:
getAvailableResource
in interfaceResourceProvisioner
- Returns:
- the amount of free available physical resource
-
isResourceAllocatedToVm
Description copied from interface:ResourceProvisioner
Checks if the resource the provisioner manages is allocated to a given Vm.- Specified by:
isResourceAllocatedToVm
in interfaceResourceProvisioner
- Parameters:
vm
- the VM to check if the resource is allocated to- Returns:
- true if the resource is allocated to the VM, false otherwise
-