Interface VmAllocationPolicy
- All Known Subinterfaces:
VmAllocationPolicyMigration
,VmAllocationPolicyMigrationDynamicUpperThreshold
- All Known Implementing Classes:
VmAllocationPolicyAbstract
,VmAllocationPolicyBestFit
,VmAllocationPolicyFirstFit
,VmAllocationPolicyMigrationAbstract
,VmAllocationPolicyMigrationBestFitStaticThreshold
,VmAllocationPolicyMigrationDynamicUpperThresholdFirstFit
,VmAllocationPolicyMigrationStaticThreshold
,VmAllocationPolicyMigrationWorstFitStaticThreshold
,VmAllocationPolicyRandom
,VmAllocationPolicyRoundRobin
,VmAllocationPolicySimple
,VmAllocationPolicyWorstFit
public interface VmAllocationPolicy
An interface to be implemented by each class that represents a policy used by
a
Datacenter
to choose a Host
to place or migrate a
given Vm
or VmGroup
.
The VmAllocationPolicy uses Java 8 Functional Programming
to enable changing, at runtime, the policy used
to select a Host for a given Vm
or VmGroup
.
- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
- See Also:
setFindHostForVmFunction(BiFunction)
-
Field Summary
Fields Modifier and Type Field Description static int
DEF_HOST_COUNT_FOR_PARALLEL_SEARCH
Default minimum number of Hosts to start using parallel search.static org.slf4j.Logger
LOGGER
static VmAllocationPolicy
NULL
A property that implements the Null Object Design Pattern forVmAllocationPolicy
objects. -
Method Summary
Modifier and Type Method Description <T extends Vm>
List<T>allocateHostForVm(Collection<T> vmCollection)
boolean
allocateHostForVm(Vm vm)
boolean
allocateHostForVm(Vm vm, Host host)
void
deallocateHostForVm(Vm vm)
Releases the host used by a VM.Optional<Host>
findHostForVm(Vm vm)
Finds a suitable host that has enough resources to place a given VM.Datacenter
getDatacenter()
Gets theDatacenter
associated to the Allocation Policy.int
getHostCountForParallelSearch()
Gets the minimum number of Hosts to start using parallel search.<T extends Host>
List<T>getHostList()
Gets the list of Hosts available in aDatacenter
, that will be used by the Allocation Policy to place VMs.Map<Vm,Host>
getOptimizedAllocationMap(List<? extends Vm> vmList)
Gets a map of optimized allocation for VMs according to current utilization and Hosts under and overloaded conditions.default boolean
isParallelHostSearchEnabled()
Checks if Host's parallel search is enabled or not.boolean
isVmMigrationSupported()
Checks if VM migrations are supported by this VmAllocationPolicy.boolean
scaleVmVertically(VerticalVmScaling scaling)
Try to scale some Vm's resource vertically up or down, respectively if: the Vm is overloaded and the Host where the Vm is placed has enough capacity the Vm is underloaded The resource to be scaled is defined by the givenVerticalVmScaling
object.void
setDatacenter(Datacenter datacenter)
Sets the Datacenter associated to the Allocation Policyvoid
setFindHostForVmFunction(BiFunction<VmAllocationPolicy,Vm,Optional<Host>> findHostForVmFunction)
Sets aBiFunction
that selects a Host for a given Vm.void
setHostCountForParallelSearch(int hostCountForParallelSearch)
Sets the minimum number of Hosts to start using parallel search.
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER -
DEF_HOST_COUNT_FOR_PARALLEL_SEARCH
static final int DEF_HOST_COUNT_FOR_PARALLEL_SEARCHDefault minimum number of Hosts to start using parallel search. -
NULL
A property that implements the Null Object Design Pattern forVmAllocationPolicy
objects.
-
-
Method Details
-
getDatacenter
Datacenter getDatacenter()Gets theDatacenter
associated to the Allocation Policy.- Returns:
-
setDatacenter
Sets the Datacenter associated to the Allocation Policy- Parameters:
datacenter
- the Datacenter to set
-
allocateHostForVm
-
allocateHostForVm
-
allocateHostForVm
-
scaleVmVertically
Try to scale some Vm's resource vertically up or down, respectively if:- the Vm is overloaded and the Host where the Vm is placed has enough capacity
- the Vm is underloaded
VerticalVmScaling
object.- Parameters:
scaling
- theVerticalVmScaling
object with information of which resource is being requested to be scaled- Returns:
- true if the requested resource was scaled, false otherwise
-
deallocateHostForVm
Releases the host used by a VM.- Parameters:
vm
- the vm to get its host released
-
setFindHostForVmFunction
void setFindHostForVmFunction(BiFunction<VmAllocationPolicy,Vm,Optional<Host>> findHostForVmFunction)Sets aBiFunction
that selects a Host for a given Vm. This Function receives the current VmAllocationPolicy and theVm
requesting to be place. It then returns anOptional<Host>
that may contain a suitable Host for that Vm or not.If not Function is set, the default VM selection method provided by implementing classes will be used.
- Parameters:
findHostForVmFunction
- theBiFunction
to set
-
getHostList
Gets the list of Hosts available in aDatacenter
, that will be used by the Allocation Policy to place VMs.- Type Parameters:
T
- The generic type- Returns:
- the host list
-
getOptimizedAllocationMap
Gets a map of optimized allocation for VMs according to current utilization and Hosts under and overloaded conditions. The conditions that will make a new VM placement map to be proposed and returned is defined by each implementing class.- Parameters:
vmList
- the list of VMs to be reallocated- Returns:
- the new vm placement map, where each key is a VM and each value is the host where such a Vm has to be placed
-
findHostForVm
Finds a suitable host that has enough resources to place a given VM. Internally it may use a default implementation or one set in runtime.- Parameters:
vm
- the vm to find a host for it- Returns:
- an
Optional
containing a suitable Host to place the VM or an emptyOptional
if no suitable Host was found - See Also:
setFindHostForVmFunction(BiFunction)
-
isVmMigrationSupported
boolean isVmMigrationSupported()Checks if VM migrations are supported by this VmAllocationPolicy. Realize that even if the policy allows VM migration, such operations can be dynamically enabled/disabled by the Datacenter.- Returns:
- See Also:
Datacenter.enableMigrations()
,Datacenter.disableMigrations()
-
isParallelHostSearchEnabled
default boolean isParallelHostSearchEnabled()Checks if Host's parallel search is enabled or not.- Returns:
- true if a Host for a VM is to find in parallel, false if it's to be find sequentially
- See Also:
setHostCountForParallelSearch(int)
-
getHostCountForParallelSearch
int getHostCountForParallelSearch()Gets the minimum number of Hosts to start using parallel search.- Returns:
-
setHostCountForParallelSearch
void setHostCountForParallelSearch(int hostCountForParallelSearch)Sets the minimum number of Hosts to start using parallel search.- Parameters:
hostCountForParallelSearch
- the value to set (useInteger.MAX_VALUE
to disable parallel search)
-