public interface VirtualMachine extends Entity, RunnableEntity
RunnableEntity
that can have multiple jobs running inside of it.
Before starting a job inside a VM, ensure that the VM is running or you will get an IllegalStateException.
All the jobs inside the VM will share its allocated resources (computing/networking/storage).
Though, you can define specific rules on how resources are provisioned inside the VM.
For example, you can set a resource limit for this VM, and/or you can define your own rules
on how the resources are shared among jobs inside the VM.
To do so you have to instantiate a provisioner for the type of resource you want, and define this VM
as its parent. Just make sure the VM is not
running before doing so, or you will get an IllegalStateException.
You can only define one provisioner per resource type (ComputingProvisioner
, StorageProvisioner
, NetworkProvisioner
).
ComputingOperation
s in this VM will seek a ProcessingUnit
using this VM's PuAllocator
.
A User
may own the VM.
RunnableEntity.RunnableState
Modifier and Type | Field and Description |
---|---|
static long |
FLAG_IS_MIGRATING
Indicates that this VM is being migrated to another host.
|
Modifier and Type | Method and Description |
---|---|
VirtualMachine |
clone()
Creates a clone of current VM, and unsets any assigned resource on that clone (usable processing units, usable storages,
usable network interfaces, virtual ram and virtual storage).
|
List<VmCheckpoint> |
getCheckpoints()
Returns a list (immutable) containing all
VmCheckpoint s owned by this VM. |
ComputingProvisioner |
getComputingProvisioner()
Returns the ComputingProvisioner for computing operations at this virtual machine level, or null if none is set.
|
int |
getEpoch()
Returns an epoch value characterizing the execution state of the VM.
|
boolean |
getFlag(long flag)
Returns true if this flag is set
|
List<Job> |
getJobs()
Returns the list of
Job s that are running on top of this VirtualMachine. |
NetworkOperationDelayer |
getNetworkOperationDelayer()
Returns the currently set
NetworkOperationDelayer for network operations in this VM. |
NetworkProvisioner |
getNetworkProvisioner()
Returns the NetworkProvisioner for network operations at this virtual machine level, or null if none is set.
|
Host |
getParent()
Returns the parent of this entity, or null if no parent is set
|
VmPlacementPolicy |
getPlacementPolicy()
Returns the
VmPlacementPolicy that was used when placing this VM in the current host or
null if this VM has no defined VmPlacementPolicy . |
PuAllocator |
getPuAllocator()
Returns the
PuAllocator associated with this VM. |
StorageProvisioner |
getStorageProvisioner()
Returns the StorageProvisioner for storage operations at this virtual machine level, or null if none is set.
|
List<NetworkInterface> |
getUsableNetworkInterfaces()
Returns the network interfaces that this virtual machine is allowed to use.
|
List<ProcessingUnit> |
getUsableProcessingUnits()
Returns the processing units that this VM can use.
|
User |
getUser()
Returns the
User that owns this Virtual Machine. |
VirtualRam |
getVirtualRam()
Returns the virtual ram of this VM.
|
VirtualStorage |
getVirtualStorage()
Returns the virtual storage associated with this VM.
|
void |
setEpoch(int epoch)
Updates the epoch value of this VM.
|
void |
setFlag(long flag)
Sets the flag.
|
void |
setNetworkOperationDelayer(NetworkOperationDelayer v)
Sets the current
NetworkOperationDelayer for network operations in this VM. |
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 |
setPlacementPolicy(VmPlacementPolicy policy)
This method is called by
VmPlacementPolicy when placing this VM on a host. |
void |
setUsableNetworkInterfaces(List<NetworkInterface> networkInterfaces)
Updates the network interfaces that this virtual machine is allowed to use.
|
void |
setUsableProcessingUnits(List<ProcessingUnit> processingUnits)
Same as
setUsableProcessingUnits(List, boolean) with
the allocatePu parameter set to true. |
void |
setUsableProcessingUnits(List<ProcessingUnit> processingUnits,
boolean allocatePu)
Updates the processing units that this VM can use.
|
void |
setUser(User user)
Updates the
User that owns this Virtual Machine. |
void |
setVirtualRam(VirtualRam v)
Updates the virtual ram associated with this VM.
|
void |
setVirtualStorage(VirtualStorage v)
Updates the virtual storage associated with this VirtualMachine.
|
void |
unsetFlag(long flag)
Unsets the flag.
|
canRestart, canStart, doCancel, doFail, doPause, doRestart, doStart, doTerminate, getRunnableState, isRunning, isTerminated, unplace
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
static final long FLAG_IS_MIGRATING
VirtualMachine clone()
The same user owns the cloned VM and it has the same SLA constraints.
Other children entities are cloned just as specified by superclass clone method.
Host getParent()
Entity
void setParent(Entity parent)
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
.
Note If you want to unplace rather than just update this VM's parent,
then use RunnableEntity.unplace()
. This method will only update current VM's parent without taking
any further actions.
setParent
in interface Entity
RunnableEntity.unplace()
VmPlacementPolicy getPlacementPolicy()
VmPlacementPolicy
that was used when placing this VM in the current host or
null if this VM has no defined VmPlacementPolicy
.VmPlacementPolicy
that was used when placing this VM or nullvoid setPlacementPolicy(VmPlacementPolicy policy)
VmPlacementPolicy
when placing this VM on a host.
You should not need to call this method if you are not implementing a placement policy.
policy
- User getUser()
User
that owns this Virtual Machine.User
that owns this Virtual MachineList<Job> getJobs()
Job
s that are running on top of this VirtualMachine.Job
s that are running on top of this VirtualMachineList<VmCheckpoint> getCheckpoints()
VmCheckpoint
s owned by this VM.VmCheckpoint
s owned by this VMList<ProcessingUnit> getUsableProcessingUnits()
Default is set so that all processing units on the parent host are usable.
void setUsableProcessingUnits(List<ProcessingUnit> processingUnits)
setUsableProcessingUnits(List, boolean)
with
the allocatePu parameter set to true.void setUsableProcessingUnits(List<ProcessingUnit> processingUnits, boolean allocatePu)
If allocatePu parameter is true, then this method will also update the allocated flag for each of the processing units in the given list. And, if one of the given processing units is already allocated then an exception is thrown.
If null is given then this VM is allowed to use any processing unit in the parent host, even if it is allocated for another VM and independently from the allocatePu parameter.
processingUnits
- usable processing units, or to null to let this vm use any processing unit on the parent hostIllegalStateException
- if this VM is runningIllegalArgumentException
- if allocatePu parameter is true and one of the PUs in the
given processingUnits list is already allocated for another VMPuAllocator getPuAllocator()
PuAllocator
associated with this VM.PuAllocator
associated with this VMVirtualRam getVirtualRam()
void setVirtualRam(VirtualRam v)
v
- IllegalStateException
- if this VM is runningIllegalArgumentException
- if the given virtual ram is already allocated for another VMVirtualStorage getVirtualStorage()
void setVirtualStorage(VirtualStorage v)
v
- IllegalStateException
- if this VM is runningIllegalArgumentException
- if the given virtual storage is already allocated for another VMList<NetworkInterface> getUsableNetworkInterfaces()
Default is set so that all interfaces on the parent host are usable.
void setUsableNetworkInterfaces(List<NetworkInterface> networkInterfaces)
If null is given then this VM is allowed to use any network interface in the parent host.
networkInterfaces
- usable network interfaces, set to null to let this vm use any network interface on the parent host.IllegalStateException
- if this VM is runningComputingProvisioner getComputingProvisioner()
A ComputingProvisioner is not mandatory for VMs. It should be used only if you want to set specific MIPS limits for this particular VM. So, for example, you can set a maximum allowable MIPS for all operations inside this VM. You can also allow specific Jobs to have more MIPS than others.
null can be returned if there is no need for special strategy at this VM level.
StorageProvisioner getStorageProvisioner()
A StorageProvisioner is not mandatory for VMs. It should be used only if you want to set specific transfer rate limits for this particular VM. So, for example, you can set a maximum allowable transfer rate for all operations inside this VM. You can also allow specific Jobs to have more transfer rate than others.
null can be returned if there is no need for special strategy at this VM level.
NetworkProvisioner getNetworkProvisioner()
A NetworkProvisioner is not mandatory for VMs. It should be used only if you want to set specific BW limits for this particular VM. So, for example, you can set a maximum allowable BW for all operations inside this VM. You can also allow specific Jobs to have more BW than others.
null can be returned if there is no need for special strategy at this VM level.
NetworkOperationDelayer getNetworkOperationDelayer()
NetworkOperationDelayer
for network operations in this VM.NetworkOperationDelayer
for network operations in this VM.void setNetworkOperationDelayer(NetworkOperationDelayer v)
NetworkOperationDelayer
for network operations in this VM.
If the VM is running, then the VM is first paused, then the NetworkOperationDelayer
is set, and finally the VM is resumed.
int getEpoch()
void setEpoch(int epoch)
epoch
- boolean getFlag(long flag)
flag
- the flag idsetFlag(long)
void setFlag(long flag)
NotificationCodes.VM_FLAG_CHANGED
notification is thrown.flag
- void unsetFlag(long flag)
flag
-