public abstract class VmPlacementPolicyAbstract extends EntityImpl implements VmPlacementPolicy
NotifierImpl.NotifyEvent
Constructor and Description |
---|
VmPlacementPolicyAbstract() |
Modifier and Type | Method and Description |
---|---|
boolean |
canPlaceVm(VirtualMachine vm,
Host host)
Returns true if the vm can be placed on the given host.
|
VmPlacementPolicyAbstract |
clone()
Creates a clone of this
Notifier . |
CloudProvider |
getParent()
Returns the parent of this entity, or null if no parent is set
|
void |
placeVm(VirtualMachine vm,
Host host)
Takes all actions in order to place the given vm on the given host.
|
Host |
selectHost(VirtualMachine vm)
Alias for
VmPlacementPolicy.selectHost(VirtualMachine, List) where
possible hosts is null. |
Host |
selectHost(VirtualMachine vm,
List<Host> hosts)
Alias for
VmPlacementPolicy.selectHost(VirtualMachine, List, List) where
excluded hosts is null. |
Host |
selectHost(VirtualMachine vm,
List<Host> hosts,
List<Host> excludedHosts)
Selects a host where to place the given vm and returns it.
|
void |
setParent(Entity parent)
Updates the parent of this entity.
This method makes sure that the old and the new parent keep their entities list updated, by automatically calling Entity.addEntity(Entity) and Entity.removeEntity(Entity) . |
void |
unplaceVm(VirtualMachine vm)
Takes all actions in order to unplaces the given vm.
When all actions were taken, the VM's parent is updated (set to null). |
addEntity, getConfig, getConfigRec, getEntities, getId, getLogger, getName, getNextId, getProperties, getProperty, getProperty, hashCode, hasParentRec, lockParent, lockParentRec, removeEntity, setConfig, setName, setProperty, toString, unlockParent, unlockParentRec, unsetProperty
addProbe, getProbe, getProbe, getProbes, removeProbe, removeProbe
addGlobalListener, addListener, cancelNotifications, cleanupListeners, disableNotifications, enableNotifications, getGlobalListeners, getListeners, isNotificationsDisabled, notify, notifyNow, removeAllGlobalListeners, removeAllListeners, removeAllListeners, removeGlobalListener, removeListener
addEntity, getConfig, getConfigRec, getEntities, getId, getLogger, getName, getProperties, getProperty, getProperty, hasParentRec, lockParent, lockParentRec, removeEntity, setConfig, setName, setProperty, unlockParent, unlockParentRec, unsetProperty
addGlobalListener, addListener, cancelNotifications, cleanupListeners, disableNotifications, enableNotifications, getGlobalListeners, getListeners, isNotificationsDisabled, notify, notifyNow, removeAllGlobalListeners, removeAllListeners, removeAllListeners, removeGlobalListener, removeListener
addProbe, getProbe, getProbe, getProbes, removeProbe, removeProbe
public VmPlacementPolicyAbstract clone()
Notifier
Notifier
.
The clone will contain a new empty listeners list and is independent from this object.
clone
in interface Entity
clone
in interface Notifier
clone
in interface VmPlacementPolicy
clone
in class EntityImpl
public CloudProvider getParent()
Entity
getParent
in interface Entity
getParent
in interface VmPlacementPolicy
getParent
in class EntityImpl
public void setParent(Entity parent)
Entity
Entity.addEntity(Entity)
and Entity.removeEntity(Entity)
.
A CoreNotificationCodes.ENTITY_PARENT_CHANGED
notification is thrown.
Additionally, each descendant of this entity (ie: entities who have this entity as their direct or not direct parent) are
notified using CoreNotificationCodes.ENTITY_ANCESTOR_CHANGED
.
setParent
in interface Entity
setParent
in class EntityImpl
public Host selectHost(VirtualMachine vm, List<Host> hosts, List<Host> excludedHosts)
VmPlacementPolicy
A host among all given hosts will be selected such that it satisfies
the virtual machine's defined SLA (defined through its configuration).
Among other conditions, the selected host must be in FailureProneEntity.FailureState.OK
state.
But, it can be in a state other than PoweredEntity.PowerState.ON
if the cloud provider's
power manager allows it to be powered on.
In which case, it is left to the placement method to power it on.
Depending on whether a host was found or not, a NotificationCodes.VMPLACEMENT_VMSELECTION_SUCCESS
or
NotificationCodes.VMPLACEMENT_VMSELECTION_FAILED
is thrown.
selectHost
in interface VmPlacementPolicy
hosts
- possible hosts. May be null in which case, all hosts in the cloud are considered.excludedHosts
- a list of hosts that should not be selected. May be null.public final Host selectHost(VirtualMachine vm, List<Host> hosts)
VmPlacementPolicy
VmPlacementPolicy.selectHost(VirtualMachine, List, List)
where
excluded hosts is null.selectHost
in interface VmPlacementPolicy
public final Host selectHost(VirtualMachine vm)
VmPlacementPolicy
VmPlacementPolicy.selectHost(VirtualMachine, List)
where
possible hosts is null.selectHost
in interface VmPlacementPolicy
public boolean canPlaceVm(VirtualMachine vm, Host host)
VmPlacementPolicy
canPlaceVm
in interface VmPlacementPolicy
public void placeVm(VirtualMachine vm, Host host)
VmPlacementPolicy
CoreNotificationCodes.ENTITY_PARENT_CHANGED
to know when the placement
has ended, as it may not be the case when this method returns.
During the placement, any needed resources (example: VirtualRam
and/or
VirtualStorage
) are instantiated and set accordingly to the vm's
SLA constraints (as defined in its configuration).
When the given vm already contains some or other resource, then
implementations must use the already set resources and must not replace them.
If the already set resources cannot comply to the SLA constraints, then an exception is thrown.
The given host may be in another state than PoweredEntity.PowerState.ON
.
If so then this method asks the cloud provider's power manger to power it on.
You need to check for the return value of VmPlacementPolicy.canPlaceVm(VirtualMachine, Host)
to
see if the vm can be placed on the given host.
If you selected the host using VmPlacementPolicy.selectHost(VirtualMachine)
then this method should succeed.
placeVm
in interface VmPlacementPolicy
vm
- the VirtualMachine
to placehost
- the Host
where to place the vmpublic void unplaceVm(VirtualMachine vm)
VmPlacementPolicy
Any allocated resource during placement
are detached from the parent host. This likely includes the VirtualRam
and the VirtualStorage
whose parents
are then set to null.
The parent host of the VM should be powered off if the cloud provider's power manger allows it to.
unplaceVm
in interface VmPlacementPolicy