public abstract class VmAllocationPolicyAbstract extends Object implements VmAllocationPolicy
Datacenter
to choose a Host
to place or migrate
a given Vm
. It supports two-stage commit of reservation of
hosts: first, we reserve the Host and, once committed by the customer, the VM is
effectively allocated to that Host.
Each Datacenter
must to have its own instance of a VmAllocationPolicy
.
DEF_HOST_COUNT_FOR_PARALLEL_SEARCH, NULL
Constructor and Description |
---|
VmAllocationPolicyAbstract()
Creates a VmAllocationPolicy.
|
VmAllocationPolicyAbstract(BiFunction<VmAllocationPolicy,Vm,Optional<Host>> findHostForVmFunction)
Creates a VmAllocationPolicy, changing the
BiFunction to select a Host for a Vm. |
Modifier and Type | Method and Description |
---|---|
boolean |
allocateHostForVm(Vm vm)
Allocates the host with less PEs in use for a given VM.
|
boolean |
allocateHostForVm(Vm vm,
Host host)
Allocates a specified host for a given VM.
|
void |
deallocateHostForVm(Vm vm)
Releases the host used by a VM.
|
protected abstract Optional<Host> |
defaultFindHostForVm(Vm vm)
Provides the default implementation of the
VmAllocationPolicy
to find a suitable Host for a given VM. |
Optional<Host> |
findHostForVm(Vm vm)
Finds a suitable host that has enough resources to place a given VM.
|
Datacenter |
getDatacenter()
Gets the
Datacenter associated to the Allocation Policy. |
int |
getHostCountForParallelSearch()
Gets the minimum number of Hosts to start using parallel search.
|
<T extends Host> |
getHostList()
Gets the list of Hosts available in a
Datacenter , 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.
|
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 given
VerticalVmScaling object. |
void |
setDatacenter(Datacenter datacenter)
Sets the Datacenter associated to the Allocation Policy
|
void |
setFindHostForVmFunction(BiFunction<VmAllocationPolicy,Vm,Optional<Host>> findHostForVmFunction)
Sets a
BiFunction that selects a Host for a given Vm. |
void |
setHostCountForParallelSearch(int hostCountForParallelSearch)
Sets the minimum number of Hosts to start using parallel search.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isParallelHostSearchEnabled
public VmAllocationPolicyAbstract()
public VmAllocationPolicyAbstract(BiFunction<VmAllocationPolicy,Vm,Optional<Host>> findHostForVmFunction)
BiFunction
to select a Host for a Vm.findHostForVmFunction
- a BiFunction
to select a Host for a given Vm.VmAllocationPolicy.setFindHostForVmFunction(BiFunction)
public final <T extends Host> List<T> getHostList()
VmAllocationPolicy
Datacenter
, that will be
used by the Allocation Policy to place VMs.getHostList
in interface VmAllocationPolicy
T
- The generic typepublic Datacenter getDatacenter()
VmAllocationPolicy
Datacenter
associated to the Allocation Policy.getDatacenter
in interface VmAllocationPolicy
public final void setDatacenter(Datacenter datacenter)
setDatacenter
in interface VmAllocationPolicy
datacenter
- the Datacenter to setpublic boolean scaleVmVertically(VerticalVmScaling scaling)
VmAllocationPolicy
VerticalVmScaling
object.scaleVmVertically
in interface VmAllocationPolicy
scaling
- the VerticalVmScaling
object with information of which resource
is being requested to be scaledpublic boolean allocateHostForVm(Vm vm)
allocateHostForVm
in interface VmAllocationPolicy
vm
- the VM to allocate a host topublic boolean allocateHostForVm(Vm vm, Host host)
VmAllocationPolicy
allocateHostForVm
in interface VmAllocationPolicy
vm
- the VM to allocate a host tohost
- the host to allocate to the given VMpublic void deallocateHostForVm(Vm vm)
VmAllocationPolicy
deallocateHostForVm
in interface VmAllocationPolicy
vm
- the vm to get its host releasedpublic final void setFindHostForVmFunction(BiFunction<VmAllocationPolicy,Vm,Optional<Host>> findHostForVmFunction)
BiFunction
that selects a Host for a given Vm.
This Function receives the current VmAllocationPolicy and the
Vm
requesting to be place.
It then returns an Optional<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.
The default implementation of such a Function is provided by the methodfindHostForVm(Vm)
.setFindHostForVmFunction
in interface VmAllocationPolicy
findHostForVmFunction
- the BiFunction
to set.
Passing null makes the default method to find a Host for a VM to be used.public final Optional<Host> findHostForVm(Vm vm)
VmAllocationPolicy
VmAllocationPolicy.setFindHostForVmFunction(BiFunction)
.findHostForVm
in interface VmAllocationPolicy
vm
- the vm to find a host for itOptional
containing a suitable Host to place the VM or an empty Optional
if no suitable Host was foundprotected abstract Optional<Host> defaultFindHostForVm(Vm vm)
VmAllocationPolicy
to find a suitable Host for a given VM.vm
- the VM to find a suitable Host toOptional
containing a suitable Host to place the VM or an empty Optional
if no suitable Host was foundsetFindHostForVmFunction(BiFunction)
public Map<Vm,Host> getOptimizedAllocationMap(List<? extends Vm> vmList)
This method implementation doesn't perform any
VM placement optimization and, in fact, has no effect.
The VmAllocationPolicyMigrationAbstract
class
provides an actual implementation for this method that can be overridden
by subclasses.
getOptimizedAllocationMap
in interface VmAllocationPolicy
vmList
- the list of VMs to be reallocatedpublic int getHostCountForParallelSearch()
VmAllocationPolicy
getHostCountForParallelSearch
in interface VmAllocationPolicy
public void setHostCountForParallelSearch(int hostCountForParallelSearch)
VmAllocationPolicy
setHostCountForParallelSearch
in interface VmAllocationPolicy
hostCountForParallelSearch
- the value to set (use Integer.MAX_VALUE
to disable parallel search)Copyright © 2015–2019 Systems, Security and Image Communication Lab - Instituto de Telecomunica����es (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educa����o Ci��ncia e Tecnologia do Tocantins (IFTO). All rights reserved.