Class VmSimple
- All Implemented Interfaces:
java.lang.Comparable<Vm>
,ChangeableId
,CustomerEntity
,Delayable
,Identifiable
,Machine
,UniquelyIdentifiable
,TimeZoned
,Resourceful
,Vm
public class VmSimple extends CustomerEntityAbstract implements Vm
Host
that may be shared among other VMs. It processes
cloudlets
. This processing happens according to a policy,
defined by the CloudletScheduler
. Each VM has a owner (user), which
can submit cloudlets to the VM to execute them.- Since:
- CloudSim Toolkit 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov
-
Field Summary
-
Constructor Summary
Constructors Constructor Description VmSimple(double mipsCapacity, long numberOfPes)
Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size.VmSimple(double mipsCapacity, long numberOfPes, CloudletScheduler cloudletScheduler)
Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size.VmSimple(long id, double mipsCapacity, long numberOfPes)
Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size.VmSimple(long id, long mipsCapacity, long numberOfPes)
Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size. -
Method Summary
Modifier and Type Method Description Vm
addExpectedFreePesNumber(long pesToAdd)
Adds a given number of expected free PEs to the total number of expected free PEs.Vm
addOnCreationFailureListener(EventListener<VmDatacenterEventInfo> listener)
Adds a listener object that will be notified when the Vm fail in being placed for lack of aHost
with enough resources in a specificDatacenter
.Vm
addOnHostAllocationListener(EventListener<VmHostEventInfo> listener)
Adds a listener object that will be notified when aHost
is allocated to the Vm, that is, when the Vm is placed into a given Host.Vm
addOnHostDeallocationListener(EventListener<VmHostEventInfo> listener)
Adds a listener object that will be notified when the Vm is moved/removed from aHost
.Vm
addOnUpdateProcessingListener(EventListener<VmHostEventInfo> listener)
Adds a listener object that will be notified every time when the processing of the Vm is updated in itsHost
.void
addStateHistoryEntry(VmStateHistoryEntry entry)
Adds a VM state history entry.void
allocateResource(java.lang.Class<? extends ResourceManageable> resourceClass, long newTotalResourceAmount)
Changes the allocation of a given resource for a VM.int
compareTo(Vm o)
Compare this Vm with another one based ongetTotalMipsCapacity()
.void
deallocateResource(java.lang.Class<? extends ResourceManageable> resourceClass)
Removes the entire amount of a given resource allocated to VM.boolean
equals(java.lang.Object o)
Resource
getBw()
Gets bandwidth resource (in Megabits/s) assigned to the Vm, allowing to check its capacity and usage.VerticalVmScaling
getBwVerticalScaling()
Gets aVerticalVmScaling
that will check if the Vm's Bandwidth is overloaded, based on some conditions defined by aPredicate
given to the VerticalVmScaling, and then request the BW up scaling.CloudletScheduler
getCloudletScheduler()
Gets the the Cloudlet scheduler the VM uses to schedule cloudlets execution.double
getCpuPercentUtilization()
Gets the current CPU utilization percentage (in scale from 0 to 1) of all Cloudlets running on this VM.double
getCpuPercentUtilization(double time)
Gets the CPU utilization percentage of all Cloudlets running on this VM at the given time.long
getCurrentRequestedBw()
Gets the current requested bw.double
getCurrentRequestedMaxMips()
Gets the current requested max MIPS among all virtualPEs
.java.util.List<java.lang.Double>
getCurrentRequestedMips()
Gets a copy list of current requested MIPS of each virtualPe
, avoiding the original list to be changed.long
getCurrentRequestedRam()
Gets the current requested ram.double
getCurrentRequestedTotalMips()
Gets the current requested total MIPS.static long
getDefaultBwCapacity()
Gets the Default Bandwidth capacity (in Mbps) for creating VMs.static long
getDefaultRamCapacity()
Gets the Default RAM capacity (in MB) for creating VMs.static long
getDefaultStorageCapacity()
Gets the Default Storage capacity (in MB) for creating VMs.java.lang.String
getDescription()
Gets the Vm description, which is an optional text which one can use to provide details about this of this VM.long
getExpectedFreePesNumber()
Gets the expected free pes number before the VM starts executing.double
getExpectedHostCpuUtilization(double vmCpuUtilizationPercent)
Computes what would be the relative percentage of the CPU the VM is using from the Host's total MIPS Capacity, considering that the VM 's CPU load is at a given percentage.long
getFreePesNumber()
Gets the current number of free PEs.VmGroup
getGroup()
Gets thegroup
this Vm belongs toHorizontalVmScaling
getHorizontalScaling()
Gets aHorizontalVmScaling
that will check if the Vm is overloaded, based on some conditions defined by aPredicate
given to the HorizontalVmScaling, and then request the creation of new VMs to horizontally scale the Vm.Host
getHost()
Gets theHost
where the Vm is or will be placed.double
getHostBwUtilization()
Computes the relative percentage of the Bandwidth the VM is using from the Host's total Capacity for the current simulation time.double
getHostCpuUtilization(double time)
Computes the relative percentage of the CPU the VM is using from the Host's total MIPS Capacity for the current simulation time.double
getHostRamUtilization()
Computes the relative percentage of the RAM the VM is using from the Host's total Capacity for the current simulation time.double
getLastBusyTime()
Gets the last time the Machine was running some process.double
getMips()
Gets the individual MIPS capacity of any machine'sPe
, considering that all PEs have the same capacity.long
getNumberOfPes()
Gets the overall number ofPe
s the machine has, that include PEs of all statuses, including failed PEs.VerticalVmScaling
getPeVerticalScaling()
Gets aVerticalVmScaling
that will check if the Vm'sPe
is overloaded, based on some conditions defined by aPredicate
given to the VerticalVmScaling, and then request the RAM up scaling.Processor
getProcessor()
Gets theProcessor
of this VM.Resource
getRam()
Gets the RAM resource assigned to the Vm, allowing to check its capacity (in Megabytes) and usage.VerticalVmScaling
getRamVerticalScaling()
Gets aVerticalVmScaling
that will check if the Vm's RAM is overloaded, based on some conditions defined by aPredicate
given to the VerticalVmScaling, and then request the RAM up scaling.java.util.List<ResourceManageable>
getResources()
Gets a read-only list of resources the machine has.double
getStartTime()
Gets the time the VM was created into some Host for the first time (in seconds).java.util.List<VmStateHistoryEntry>
getStateHistory()
Gets a read-only list with the history of requests and allocation of MIPS for this VM.double
getStopTime()
Gets the time the VM was destroyed into the last Host it executed (in seconds).Resource
getStorage()
Gets the storage device of the VM, which represents the VM image, allowing to check its capacity (in Megabytes) and usage.double
getSubmissionDelay()
Gets the time (in seconds) that aDatacenterBroker
will wait to request the creation of the object.double
getTimeZone()
Gets the time zone offset, a value between [-12 and 12], in which the VM is expected to be placed (if there is aDatacenter
with enough capacity available at that timezone).double
getTotalCpuMipsUtilization()
Gets the current total CPU MIPS utilization of all PEs from all cloudlets running on this VM.double
getTotalCpuMipsUtilization(double time)
Gets the total CPU MIPS utilization of all PEs from all cloudlets running on this VM at the given time.double
getTotalExecutionTime()
Gets the total time (in seconds) the Vm spent executing.double
getTotalMipsCapacity()
Gets total MIPS capacity of all PEs of the machine.UtilizationHistory
getUtilizationHistory()
Gets the object containing CPU utilization percentage history (between [0 and 1], where 1 is 100%).java.lang.String
getVmm()
Gets the Virtual Machine Monitor (VMM) that manages the VM.boolean
hasStartedSomeCloudlet()
Checks if the VM has ever started some Cloudlet.boolean
isCreated()
Checks if the VM was created and placed inside theHost
.boolean
isFailed()
Checks if the Vm is failed or not.boolean
isInMigration()
Checks if the VM is in migration process or not, that is, if it is migrating in or out of a Host.boolean
isSuitableForCloudlet(Cloudlet cloudlet)
Checks if the VM has enough capacity to run a Cloudlet.boolean
isWorking()
Checks if the Vm is working or failed.void
notifyOnCreationFailureListeners(Datacenter failedDatacenter)
Notifies all registered listeners when the Vm fail in being placed for lack of aHost
with enough resources in a specificDatacenter
.void
notifyOnHostAllocationListeners()
void
notifyOnHostDeallocationListeners(Host deallocatedHost)
void
notifyOnUpdateProcessingListeners()
Notifies all registered listeners when the processing of the Vm is updated in itsHost
.Vm
removeExpectedFreePesNumber(long pesToRemove)
Adds a given number of expected free PEs to the total number of expected free PEs.boolean
removeOnCreationFailureListener(EventListener<VmDatacenterEventInfo> listener)
Removes a listener from the onVmCreationFailureListener List.boolean
removeOnHostAllocationListener(EventListener<VmHostEventInfo> listener)
Removes a listener from the onHostAllocationListener List.boolean
removeOnHostDeallocationListener(EventListener<VmHostEventInfo> listener)
Removes a listener from the onHostDeallocationListener List.boolean
removeOnUpdateProcessingListener(EventListener<VmHostEventInfo> listener)
Removes a listener from the onUpdateVmProcessingListener List.Vm
setBw(long bwCapacity)
Sets the bandwidth capacity (in Megabits/s)Vm
setBwVerticalScaling(VerticalVmScaling bwVerticalScaling)
Sets aVerticalVmScaling
that will check if the Vm'sBandwidth
is under or overloaded, based on some conditions defined byPredicate
s given to the VerticalVmScaling, and then request the Bandwidth up or down scaling.Vm
setCloudletScheduler(CloudletScheduler cloudletScheduler)
Sets the Cloudlet scheduler the Vm uses to schedule cloudlets execution.void
setCreated(boolean created)
Changes the created status of the Vm inside the Host.static void
setDefaultBwCapacity(long defaultCapacity)
Sets the Default Bandwidth capacity (in Mbps) for creating VMs.static void
setDefaultRamCapacity(long defaultCapacity)
Sets the Default RAM capacity (in MB) for creating VMs.static void
setDefaultStorageCapacity(long defaultCapacity)
Sets the Default Storage capacity (in MB) for creating VMs.Vm
setDescription(java.lang.String description)
Sets the VM description, which is an optional text which one can use to provide details about this of this VM.void
setFailed(boolean failed)
Sets the status of VM to FAILED.Vm
setFreePesNumber(long freePesNumber)
Sets the current number of free PEs.void
setGroup(VmGroup group)
Vm
setHorizontalScaling(HorizontalVmScaling horizontalScaling)
Sets aHorizontalVmScaling
that will check if the Vm is overloaded, based on some conditions defined by aPredicate
given to the HorizontalVmScaling, and then request the creation of new VMs to horizontally scale the Vm.void
setHost(Host host)
Sets the PM that hosts the VM.void
setInMigration(boolean migrating)
Defines if the VM is in migration process or not.protected void
setMips(double mips)
Sets the individual MIPS capacity of any VM's PE, considering that all PEs have the same capacity.Vm
setPeVerticalScaling(VerticalVmScaling peVerticalScaling)
Sets aVerticalVmScaling
that will check if the Vm'sPe
is under or overloaded, based on some conditions defined byPredicate
s given to the VerticalVmScaling, and then request the Pe up or down scaling.Vm
setRam(long ramCapacity)
Sets RAM capacity in Megabytes.Vm
setRamVerticalScaling(VerticalVmScaling ramVerticalScaling)
Sets aVerticalVmScaling
that will check if the Vm'sRam
is under or overloaded, based on some conditions defined byPredicate
s given to the VerticalVmScaling, and then request the RAM up or down scaling.Vm
setSize(long size)
Sets the storage size (capacity) of the VM image in Megabytes.Vm
setStartTime(double startTime)
Sets the time the VM was created into some Host for the first time.Vm
setStopTime(double stopTime)
Sets the time the VM was destroyed into the last Host it executed (in seconds).void
setSubmissionDelay(double submissionDelay)
Sets the time (in seconds) that aDatacenterBroker
will wait to request the creation of the object.Vm
setTimeZone(double timeZone)
Sets the time zone offset, a value between [-12 and 12], in which the VM is expected to be placed (if there is aDatacenter
with enough capacity available at that timezone).protected void
setVmm(java.lang.String vmm)
Sets the Virtual Machine Monitor (VMM) that manages the VM.java.lang.String
toString()
double
updateProcessing(double currentTime, java.util.List<java.lang.Double> mipsShare)
Updates the processing of cloudlets running on this VM.double
updateProcessing(java.util.List<java.lang.Double> mipsShare)
Updates the processing of cloudlets running on this VM at the current simulation time.Methods inherited from class org.cloudbus.cloudsim.core.CustomerEntityAbstract
getBroker, getId, getLastTriedDatacenter, getSimulation, getUid, hashCode, setBroker, setId, setLastTriedDatacenter
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cloudbus.cloudsim.core.CustomerEntity
getLastTriedDatacenter, getSimulation, setLastTriedDatacenter
Methods inherited from interface org.cloudbus.cloudsim.core.Machine
getIdleInterval, getSimulation, isIdle
Methods inherited from interface org.cloudbus.cloudsim.vms.Vm
getBroker, getHostCpuUtilization, isIdleEnough, setBroker
-
Constructor Details
-
VmSimple
public VmSimple(double mipsCapacity, long numberOfPes)Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size. To change these values, use the respective setters. While the Vmis being instantiated
, such values can be changed freely.It is not defined an id for the Vm. The id is defined when the Vm is submitted to a
DatacenterBroker
.NOTE: The Vm will use a
CloudletSchedulerTimeShared
by default. If you need to change that, just callsetCloudletScheduler(CloudletScheduler)
.- Parameters:
mipsCapacity
- the mips capacity of each VmPe
numberOfPes
- amount ofPe
(CPU cores)- See Also:
setRam(long)
,setBw(long)
,setStorage(Storage)
,setDefaultRamCapacity(long)
,setDefaultBwCapacity(long)
,setDefaultStorageCapacity(long)
-
VmSimple
Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size. To change these values, use the respective setters. While the Vmis being instantiated
, such values can be changed freely.It is not defined an id for the Vm. The id is defined when the Vm is submitted to a
DatacenterBroker
.- Parameters:
mipsCapacity
- the mips capacity of each VmPe
numberOfPes
- amount ofPe
(CPU cores)- See Also:
setRam(long)
,setBw(long)
,setStorage(Storage)
,setDefaultRamCapacity(long)
,setDefaultBwCapacity(long)
,setDefaultStorageCapacity(long)
-
VmSimple
public VmSimple(long id, double mipsCapacity, long numberOfPes)Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size.To change these values, use the respective setters. While the Vm
is being instantiated
, such values can be changed freely.It receives the amount of MIPS as a double value but converts it internally to a long. The method is just provided as a handy-way to create a Vm using a double value for MIPS that usually is generated from some computations.
NOTE: The Vm will use a
CloudletSchedulerTimeShared
by default. If you need to change that, just callsetCloudletScheduler(CloudletScheduler)
.- Parameters:
id
- unique ID of the VMmipsCapacity
- the mips capacity of each VmPe
numberOfPes
- amount ofPe
(CPU cores)- See Also:
setRam(long)
,setBw(long)
,setStorage(Storage)
,setDefaultRamCapacity(long)
,setDefaultBwCapacity(long)
,setDefaultStorageCapacity(long)
-
VmSimple
public VmSimple(long id, long mipsCapacity, long numberOfPes)Creates a Vm with 1024 MEGA of RAM, 100 Megabits/s of Bandwidth and 1024 MEGA of Storage Size.To change these values, use the respective setters. While the Vm
is being instantiated
, such values can be changed freely.NOTE: The Vm will use a
CloudletSchedulerTimeShared
by default. If you need to change that, just callsetCloudletScheduler(CloudletScheduler)
.- Parameters:
id
- unique ID of the VMmipsCapacity
- the mips capacity of each VmPe
numberOfPes
- amount ofPe
(CPU cores)- See Also:
setRam(long)
,setBw(long)
,setStorage(Storage)
,setDefaultRamCapacity(long)
,setDefaultBwCapacity(long)
,setDefaultStorageCapacity(long)
-
-
Method Details
-
updateProcessing
public double updateProcessing(java.util.List<java.lang.Double> mipsShare)Description copied from interface:Vm
Updates the processing of cloudlets running on this VM at the current simulation time.- Specified by:
updateProcessing
in interfaceVm
- Parameters:
mipsShare
- list with MIPS share of each Pe available to the scheduler- Returns:
- the predicted completion time of the earliest finishing cloudlet
(which is a relative delay from the current simulation time),
or
Double.MAX_VALUE
if there is no next Cloudlet to execute
-
updateProcessing
public double updateProcessing(double currentTime, java.util.List<java.lang.Double> mipsShare)Description copied from interface:Vm
Updates the processing of cloudlets running on this VM.- Specified by:
updateProcessing
in interfaceVm
- Parameters:
currentTime
- current simulation timemipsShare
- list with MIPS share of each Pe available to the scheduler- Returns:
- the predicted completion time of the earliest finishing cloudlet
(which is a relative delay from the current simulation time),
or
Double.MAX_VALUE
if there is no next Cloudlet to execute
-
getFreePesNumber
public long getFreePesNumber()Description copied from interface:Vm
Gets the current number of free PEs.- Specified by:
getFreePesNumber
in interfaceVm
- Returns:
- the current free pes number
-
setFreePesNumber
Sets the current number of free PEs.- Returns:
- the new free pes number
-
getExpectedFreePesNumber
public long getExpectedFreePesNumber()Description copied from interface:Vm
Gets the expected free pes number before the VM starts executing. This value is updated as cloudlets are assigned to VMs but not submitted to the broker yet for running.- Specified by:
getExpectedFreePesNumber
in interfaceVm
- Returns:
- the expected free pes number
-
addExpectedFreePesNumber
Adds a given number of expected free PEs to the total number of expected free PEs. This value is updated as cloudlets are assigned to VMs but not submitted to the broker for running yet.- Parameters:
pesToAdd
- the number of expected free PEs to add
-
removeExpectedFreePesNumber
Adds a given number of expected free PEs to the total number of expected free PEs. This value is updated as cloudlets are assigned to VMs but not submitted to the broker for running yet.- Parameters:
pesToRemove
- the number of expected free PEs to remove
-
getCpuPercentUtilization
public double getCpuPercentUtilization()Description copied from interface:Vm
Gets the current CPU utilization percentage (in scale from 0 to 1) of all Cloudlets running on this VM.- Specified by:
getCpuPercentUtilization
in interfaceVm
- Returns:
- total utilization percentage for the current time, in scale from 0 to 1
-
getCpuPercentUtilization
public double getCpuPercentUtilization(double time)Description copied from interface:Vm
Gets the CPU utilization percentage of all Cloudlets running on this VM at the given time.- Specified by:
getCpuPercentUtilization
in interfaceVm
- Parameters:
time
- the time- Returns:
- total utilization percentage
-
getHostCpuUtilization
public double getHostCpuUtilization(double time)Description copied from interface:Vm
Computes the relative percentage of the CPU the VM is using from the Host's total MIPS Capacity for the current simulation time. If the capacity is 1000 MIPS and the VM is using 250 MIPS, it's equivalent to 25% of the Host's capacity.- Specified by:
getHostCpuUtilization
in interfaceVm
- Parameters:
time
- the time to get the relative VM CPU utilization- Returns:
- the relative VM CPU usage percent (from 0 to 1)
-
getExpectedHostCpuUtilization
public final double getExpectedHostCpuUtilization(double vmCpuUtilizationPercent)Description copied from interface:Vm
Computes what would be the relative percentage of the CPU the VM is using from the Host's total MIPS Capacity, considering that the VM 's CPU load is at a given percentage.- Specified by:
getExpectedHostCpuUtilization
in interfaceVm
- Returns:
- the relative VM CPU usage percent (from 0 to 1)
- See Also:
Vm.getHostCpuUtilization()
,Vm.getHostCpuUtilization(double)
-
getHostRamUtilization
public double getHostRamUtilization()Description copied from interface:Vm
Computes the relative percentage of the RAM the VM is using from the Host's total Capacity for the current simulation time.- Specified by:
getHostRamUtilization
in interfaceVm
- Returns:
- the relative VM RAM usage percent (from 0 to 1)
-
getHostBwUtilization
public double getHostBwUtilization()Description copied from interface:Vm
Computes the relative percentage of the Bandwidth the VM is using from the Host's total Capacity for the current simulation time.- Specified by:
getHostBwUtilization
in interfaceVm
- Returns:
- the relative VM BW usage percent (from 0 to 1)
-
getTotalCpuMipsUtilization
public double getTotalCpuMipsUtilization()Description copied from interface:Vm
Gets the current total CPU MIPS utilization of all PEs from all cloudlets running on this VM.- Specified by:
getTotalCpuMipsUtilization
in interfaceVm
- Returns:
- total CPU utilization in MIPS
- See Also:
Vm.getCpuPercentUtilization(double)
-
getTotalCpuMipsUtilization
public double getTotalCpuMipsUtilization(double time)Description copied from interface:Vm
Gets the total CPU MIPS utilization of all PEs from all cloudlets running on this VM at the given time.- Specified by:
getTotalCpuMipsUtilization
in interfaceVm
- Parameters:
time
- the time to get the utilization- Returns:
- total CPU utilization in MIPS
- See Also:
Vm.getCpuPercentUtilization(double)
-
getCurrentRequestedMaxMips
public double getCurrentRequestedMaxMips()Description copied from interface:Vm
Gets the current requested max MIPS among all virtualPEs
.- Specified by:
getCurrentRequestedMaxMips
in interfaceVm
- Returns:
- the current requested max MIPS
-
getCurrentRequestedTotalMips
public double getCurrentRequestedTotalMips()Description copied from interface:Vm
Gets the current requested total MIPS. It is the sum of MIPS capacity requested for every virtualPe
.- Specified by:
getCurrentRequestedTotalMips
in interfaceVm
- Returns:
- the current requested total MIPS
- See Also:
Vm.getCurrentRequestedMips()
-
getCurrentRequestedMips
public java.util.List<java.lang.Double> getCurrentRequestedMips()Description copied from interface:Vm
Gets a copy list of current requested MIPS of each virtualPe
, avoiding the original list to be changed.- Specified by:
getCurrentRequestedMips
in interfaceVm
- Returns:
- the current requested MIPS of each Pe
-
getCurrentRequestedBw
public long getCurrentRequestedBw()Description copied from interface:Vm
Gets the current requested bw.- Specified by:
getCurrentRequestedBw
in interfaceVm
- Returns:
- the current requested bw
-
getTotalMipsCapacity
public double getTotalMipsCapacity()Description copied from interface:Machine
Gets total MIPS capacity of all PEs of the machine.- Specified by:
getTotalMipsCapacity
in interfaceMachine
- Returns:
- the total MIPS of all PEs
-
getCurrentRequestedRam
public long getCurrentRequestedRam()Description copied from interface:Vm
Gets the current requested ram.- Specified by:
getCurrentRequestedRam
in interfaceVm
- Returns:
- the current requested ram
-
getStartTime
public double getStartTime()Description copied from interface:Vm
Gets the time the VM was created into some Host for the first time (in seconds). The value -1 means the VM was not created yet.- Specified by:
getStartTime
in interfaceVm
- Returns:
-
setStartTime
Description copied from interface:Vm
Sets the time the VM was created into some Host for the first time. The value -1 means the VM was not created yet.- Specified by:
setStartTime
in interfaceVm
- Parameters:
startTime
- the start time to set (in seconds)- Returns:
-
getStopTime
public double getStopTime()Description copied from interface:Vm
Gets the time the VM was destroyed into the last Host it executed (in seconds). The value -1 means the VM has not stopped or has not even started yet.- Specified by:
getStopTime
in interfaceVm
- Returns:
- See Also:
Vm.isCreated()
-
setStopTime
Description copied from interface:Vm
Sets the time the VM was destroyed into the last Host it executed (in seconds). The value -1 means the VM has not stopped or has not even started yet.- Specified by:
setStopTime
in interfaceVm
- Parameters:
stopTime
- the stop time to set (in seconds)- Returns:
- See Also:
Vm.isCreated()
-
getLastBusyTime
public double getLastBusyTime()Description copied from interface:Machine
Gets the last time the Machine was running some process.- Specified by:
getLastBusyTime
in interfaceMachine
- Returns:
- the last busy time (in seconds)
-
hasStartedSomeCloudlet
public boolean hasStartedSomeCloudlet()Checks if the VM has ever started some Cloudlet.- Returns:
-
getTotalExecutionTime
public double getTotalExecutionTime()Description copied from interface:Vm
Gets the total time (in seconds) the Vm spent executing. It considers the entire VM execution even if in different Hosts it has possibly migrated.- Specified by:
getTotalExecutionTime
in interfaceVm
- Returns:
- the VM total execution time if the VM has stopped, the time executed so far if the VM is running yet, or 0 if it hasn't started.
-
getMips
public double getMips()Description copied from interface:Machine
Gets the individual MIPS capacity of any machine'sPe
, considering that all PEs have the same capacity. -
setMips
protected final void setMips(double mips)Sets the individual MIPS capacity of any VM's PE, considering that all PEs have the same capacity.- Parameters:
mips
- the new mips for every VM's PE
-
getNumberOfPes
public long getNumberOfPes()Description copied from interface:Machine
Gets the overall number ofPe
s the machine has, that include PEs of all statuses, including failed PEs.- Specified by:
getNumberOfPes
in interfaceMachine
- Returns:
- the machine's number of PEs
-
getProcessor
Description copied from interface:Vm
- Specified by:
getProcessor
in interfaceVm
- Returns:
-
getRam
Description copied from interface:Vm
Gets the RAM resource assigned to the Vm, allowing to check its capacity (in Megabytes) and usage. -
setRam
Description copied from interface:Vm
Sets RAM capacity in Megabytes. -
getBw
Description copied from interface:Vm
Gets bandwidth resource (in Megabits/s) assigned to the Vm, allowing to check its capacity and usage. -
setBw
Description copied from interface:Vm
Sets the bandwidth capacity (in Megabits/s) -
getStorage
Description copied from interface:Vm
Gets the storage device of the VM, which represents the VM image, allowing to check its capacity (in Megabytes) and usage.- Specified by:
getStorage
in interfaceMachine
- Specified by:
getStorage
in interfaceVm
- Returns:
- the storage resource
-
setSize
Description copied from interface:Vm
Sets the storage size (capacity) of the VM image in Megabytes. -
getVmm
public java.lang.String getVmm()Description copied from interface:Vm
Gets the Virtual Machine Monitor (VMM) that manages the VM. -
setVmm
protected final void setVmm(java.lang.String vmm)Sets the Virtual Machine Monitor (VMM) that manages the VM.- Parameters:
vmm
- the new VMM
-
setHost
Description copied from interface:Vm
Sets the PM that hosts the VM. -
getHost
Description copied from interface:Vm
Gets theHost
where the Vm is or will be placed. To know if the Vm was already created inside this Host, call theVm.isCreated()
method.- Specified by:
getHost
in interfaceVm
- Returns:
- the Host
- See Also:
Vm.isCreated()
-
getCloudletScheduler
Description copied from interface:Vm
Gets the the Cloudlet scheduler the VM uses to schedule cloudlets execution.- Specified by:
getCloudletScheduler
in interfaceVm
- Returns:
- the cloudlet scheduler
-
setCloudletScheduler
Description copied from interface:Vm
Sets the Cloudlet scheduler the Vm uses to schedule cloudlets execution. It also sets the Vm itself to the given scheduler.- Specified by:
setCloudletScheduler
in interfaceVm
- Parameters:
cloudletScheduler
- the cloudlet scheduler to set- Returns:
-
isInMigration
public boolean isInMigration()Description copied from interface:Vm
Checks if the VM is in migration process or not, that is, if it is migrating in or out of a Host.- Specified by:
isInMigration
in interfaceVm
- Returns:
-
setInMigration
public final void setInMigration(boolean migrating)Description copied from interface:Vm
Defines if the VM is in migration process or not.- Specified by:
setInMigration
in interfaceVm
- Parameters:
migrating
- true to indicate the VM is migrating into a Host, false otherwise
-
isCreated
public boolean isCreated()Description copied from interface:Vm
Checks if the VM was created and placed inside theHost
. If so, resources required by the Vm already were provisioned. -
isSuitableForCloudlet
Description copied from interface:Vm
Checks if the VM has enough capacity to run a Cloudlet.- Specified by:
isSuitableForCloudlet
in interfaceVm
- Parameters:
cloudlet
- the candidate Cloudlet to run inside the VM- Returns:
- true if the VM can run the Cloudlet, false otherwise
-
setCreated
public void setCreated(boolean created)Description copied from interface:Vm
Changes the created status of the Vm inside the Host.- Specified by:
setCreated
in interfaceVm
- Parameters:
created
- true to indicate the VM was created inside the Host; false otherwise- See Also:
Vm.isCreated()
-
getStateHistory
Description copied from interface:Vm
Gets a read-only list with the history of requests and allocation of MIPS for this VM. The VM state history is just collected and stored if the Host is storing such a data.- Specified by:
getStateHistory
in interfaceVm
- Returns:
- the state history
- See Also:
Host.enableStateHistory()
-
addStateHistoryEntry
Description copied from interface:Vm
Adds a VM state history entry.- Specified by:
addStateHistoryEntry
in interfaceVm
- Parameters:
entry
- the data about the state of the VM at given time
-
allocateResource
public void allocateResource(java.lang.Class<? extends ResourceManageable> resourceClass, long newTotalResourceAmount)Description copied from interface:Vm
Changes the allocation of a given resource for a VM. The old allocated amount will be changed to the new given amount.- Specified by:
allocateResource
in interfaceVm
- Parameters:
resourceClass
- the class of the resource to change the allocationnewTotalResourceAmount
- the new amount to change the current allocation to
-
deallocateResource
Description copied from interface:Vm
Removes the entire amount of a given resource allocated to VM.- Specified by:
deallocateResource
in interfaceVm
- Parameters:
resourceClass
- the class of the resource to deallocate from the VM
-
getResources
Description copied from interface:Vm
Gets a read-only list of resources the machine has. Such resources represent virtual resources corresponding to physical resources from the Host where the VM is placed.- Specified by:
getResources
in interfaceResourceful
- Specified by:
getResources
in interfaceVm
- Returns:
- a read-only list of resources
- See Also:
Resourceful.getResource(Class)
-
addOnHostAllocationListener
Description copied from interface:Vm
Adds a listener object that will be notified when aHost
is allocated to the Vm, that is, when the Vm is placed into a given Host.- Specified by:
addOnHostAllocationListener
in interfaceVm
- Parameters:
listener
- the listener to add- Returns:
-
addOnHostDeallocationListener
Description copied from interface:Vm
Adds a listener object that will be notified when the Vm is moved/removed from aHost
.- Specified by:
addOnHostDeallocationListener
in interfaceVm
- Parameters:
listener
- the listener to add- Returns:
-
addOnCreationFailureListener
Description copied from interface:Vm
Adds a listener object that will be notified when the Vm fail in being placed for lack of aHost
with enough resources in a specificDatacenter
.The
DatacenterBroker
is accountable for receiving the notification from the Datacenter and notifying the Listeners.- Specified by:
addOnCreationFailureListener
in interfaceVm
- Parameters:
listener
- the listener to add- Returns:
- See Also:
Vm.updateProcessing(double, List)
-
addOnUpdateProcessingListener
Description copied from interface:Vm
Adds a listener object that will be notified every time when the processing of the Vm is updated in itsHost
.- Specified by:
addOnUpdateProcessingListener
in interfaceVm
- Parameters:
listener
- the listener to add- Returns:
- See Also:
Vm.updateProcessing(double, List)
-
removeOnCreationFailureListener
Description copied from interface:Vm
Removes a listener from the onVmCreationFailureListener List.- Specified by:
removeOnCreationFailureListener
in interfaceVm
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
-
removeOnUpdateProcessingListener
Description copied from interface:Vm
Removes a listener from the onUpdateVmProcessingListener List.- Specified by:
removeOnUpdateProcessingListener
in interfaceVm
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
-
removeOnHostAllocationListener
Description copied from interface:Vm
Removes a listener from the onHostAllocationListener List.- Specified by:
removeOnHostAllocationListener
in interfaceVm
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
-
removeOnHostDeallocationListener
Description copied from interface:Vm
Removes a listener from the onHostDeallocationListener List.- Specified by:
removeOnHostDeallocationListener
in interfaceVm
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
compareTo
Compare this Vm with another one based ongetTotalMipsCapacity()
.- Specified by:
compareTo
in interfacejava.lang.Comparable<Vm>
- Parameters:
o
- the Vm to compare to- Returns:
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
setFailed
public void setFailed(boolean failed)Description copied from interface:Vm
Sets the status of VM to FAILED. -
isFailed
public boolean isFailed()Description copied from interface:Vm
Checks if the Vm is failed or not.- Specified by:
isFailed
in interfaceVm
- Returns:
- See Also:
Vm.isWorking()
-
isWorking
public boolean isWorking()Description copied from interface:Vm
Checks if the Vm is working or failed.- Specified by:
isWorking
in interfaceVm
- Returns:
- See Also:
Vm.isFailed()
-
getSubmissionDelay
public double getSubmissionDelay()Description copied from interface:Delayable
Gets the time (in seconds) that aDatacenterBroker
will wait to request the creation of the object. This is a relative time from the current simulation time.- Specified by:
getSubmissionDelay
in interfaceDelayable
- Returns:
- the submission delay (in seconds)
-
setSubmissionDelay
public final void setSubmissionDelay(double submissionDelay)Description copied from interface:Delayable
Sets the time (in seconds) that aDatacenterBroker
will wait to request the creation of the object. This is a relative time from the current simulation time.- Specified by:
setSubmissionDelay
in interfaceDelayable
- Parameters:
submissionDelay
- the amount of seconds from the current simulation time that the object will wait to be submitted
-
notifyOnHostAllocationListeners
public void notifyOnHostAllocationListeners()Description copied from interface:Vm
Notifies all registered listeners when aHost
is allocated to theVm
.This method is used just internally and must not be called directly.
- Specified by:
notifyOnHostAllocationListeners
in interfaceVm
-
notifyOnHostDeallocationListeners
Description copied from interface:Vm
Notifies all registered listeners when theVm
is moved/removed from aHost
.This method is used just internally and must not be called directly.
- Specified by:
notifyOnHostDeallocationListeners
in interfaceVm
- Parameters:
deallocatedHost
- theHost
theVm
was moved/removed from
-
notifyOnUpdateProcessingListeners
public void notifyOnUpdateProcessingListeners()Notifies all registered listeners when the processing of the Vm is updated in itsHost
. -
notifyOnCreationFailureListeners
Description copied from interface:Vm
Notifies all registered listeners when the Vm fail in being placed for lack of aHost
with enough resources in a specificDatacenter
.This method is used just internally and must not be called directly.
- Specified by:
notifyOnCreationFailureListeners
in interfaceVm
- Parameters:
failedDatacenter
- the Datacenter where the VM creation failed
-
getHorizontalScaling
Description copied from interface:Vm
Gets aHorizontalVmScaling
that will check if the Vm is overloaded, based on some conditions defined by aPredicate
given to the HorizontalVmScaling, and then request the creation of new VMs to horizontally scale the Vm.If no HorizontalVmScaling is set, the
Broker
will not dynamically create VMs to balance arrived Cloudlets.- Specified by:
getHorizontalScaling
in interfaceVm
- Returns:
-
setHorizontalScaling
public final Vm setHorizontalScaling(HorizontalVmScaling horizontalScaling) throws java.lang.IllegalArgumentExceptionDescription copied from interface:Vm
Sets aHorizontalVmScaling
that will check if the Vm is overloaded, based on some conditions defined by aPredicate
given to the HorizontalVmScaling, and then request the creation of new VMs to horizontally scale the Vm.- Specified by:
setHorizontalScaling
in interfaceVm
- Parameters:
horizontalScaling
- the HorizontalVmScaling to set- Returns:
- Throws:
java.lang.IllegalArgumentException
- if the given VmScaling is already linked to a Vm. Each VM must have its own HorizontalVmScaling object or none at all.
-
setRamVerticalScaling
public final Vm setRamVerticalScaling(VerticalVmScaling ramVerticalScaling) throws java.lang.IllegalArgumentExceptionDescription copied from interface:Vm
Sets aVerticalVmScaling
that will check if the Vm'sRam
is under or overloaded, based on some conditions defined byPredicate
s given to the VerticalVmScaling, and then request the RAM up or down scaling.- Specified by:
setRamVerticalScaling
in interfaceVm
- Parameters:
ramVerticalScaling
- the VerticalVmScaling to set- Returns:
- Throws:
java.lang.IllegalArgumentException
- if the given VmScaling is already linked to a Vm. Each VM must have its own VerticalVmScaling objects or none at all.
-
setBwVerticalScaling
public final Vm setBwVerticalScaling(VerticalVmScaling bwVerticalScaling) throws java.lang.IllegalArgumentExceptionDescription copied from interface:Vm
Sets aVerticalVmScaling
that will check if the Vm'sBandwidth
is under or overloaded, based on some conditions defined byPredicate
s given to the VerticalVmScaling, and then request the Bandwidth up or down scaling.- Specified by:
setBwVerticalScaling
in interfaceVm
- Parameters:
bwVerticalScaling
- the VerticalVmScaling to set- Returns:
- Throws:
java.lang.IllegalArgumentException
- if the given VmScaling is already linked to a Vm. Each VM must have its own VerticalVmScaling objects or none at all.
-
setPeVerticalScaling
public final Vm setPeVerticalScaling(VerticalVmScaling peVerticalScaling) throws java.lang.IllegalArgumentExceptionDescription copied from interface:Vm
Sets aVerticalVmScaling
that will check if the Vm'sPe
is under or overloaded, based on some conditions defined byPredicate
s given to the VerticalVmScaling, and then request the Pe up or down scaling.The Pe scaling is performed by adding or removing PEs to/from the VM. Added PEs will have the same MIPS than the already existing ones.
- Specified by:
setPeVerticalScaling
in interfaceVm
- Parameters:
peVerticalScaling
- the VerticalVmScaling to set- Returns:
- Throws:
java.lang.IllegalArgumentException
- if the given VmScaling is already linked to a Vm. Each VM must have its own VerticalVmScaling objects or none at all.
-
getRamVerticalScaling
Description copied from interface:Vm
Gets aVerticalVmScaling
that will check if the Vm's RAM is overloaded, based on some conditions defined by aPredicate
given to the VerticalVmScaling, and then request the RAM up scaling.- Specified by:
getRamVerticalScaling
in interfaceVm
- Returns:
-
getBwVerticalScaling
Description copied from interface:Vm
Gets aVerticalVmScaling
that will check if the Vm's Bandwidth is overloaded, based on some conditions defined by aPredicate
given to the VerticalVmScaling, and then request the BW up scaling.- Specified by:
getBwVerticalScaling
in interfaceVm
- Returns:
-
getPeVerticalScaling
Description copied from interface:Vm
Gets aVerticalVmScaling
that will check if the Vm'sPe
is overloaded, based on some conditions defined by aPredicate
given to the VerticalVmScaling, and then request the RAM up scaling.- Specified by:
getPeVerticalScaling
in interfaceVm
- Returns:
-
getDescription
public java.lang.String getDescription()Description copied from interface:Vm
Gets the Vm description, which is an optional text which one can use to provide details about this of this VM.- Specified by:
getDescription
in interfaceVm
- Returns:
-
setDescription
Description copied from interface:Vm
Sets the VM description, which is an optional text which one can use to provide details about this of this VM.- Specified by:
setDescription
in interfaceVm
- Parameters:
description
- the Vm description to set- Returns:
-
getGroup
Description copied from interface:Vm
Gets thegroup
this Vm belongs to -
setGroup
-
getUtilizationHistory
Description copied from interface:Vm
Gets the object containing CPU utilization percentage history (between [0 and 1], where 1 is 100%). The history can be obtained by callingVmUtilizationHistory.getHistory()
. Initially, the data collection is disabled. To enable it callVmUtilizationHistory.enable()
.Utilization history for Hosts, obtained by calling
Host.getUtilizationHistory()
is just available if the utilization history for its VM is enabled.The time interval in which utilization is collected is defined by the
Datacenter.getSchedulingInterval()
.- Specified by:
getUtilizationHistory
in interfaceVm
- Returns:
- See Also:
UtilizationHistory.enable()
-
getDefaultRamCapacity
public static long getDefaultRamCapacity()Gets the Default RAM capacity (in MB) for creating VMs. This value is used when the RAM capacity is not given in a VM constructor. -
setDefaultRamCapacity
public static void setDefaultRamCapacity(long defaultCapacity)Sets the Default RAM capacity (in MB) for creating VMs. This value is used when the RAM capacity is not given in a VM constructor. -
getDefaultBwCapacity
public static long getDefaultBwCapacity()Gets the Default Bandwidth capacity (in Mbps) for creating VMs. This value is used when the BW capacity is not given in a VM constructor. -
setDefaultBwCapacity
public static void setDefaultBwCapacity(long defaultCapacity)Sets the Default Bandwidth capacity (in Mbps) for creating VMs. This value is used when the BW capacity is not given in a VM constructor. -
getDefaultStorageCapacity
public static long getDefaultStorageCapacity()Gets the Default Storage capacity (in MB) for creating VMs. This value is used when the Storage capacity is not given in a VM constructor. -
setDefaultStorageCapacity
public static void setDefaultStorageCapacity(long defaultCapacity)Sets the Default Storage capacity (in MB) for creating VMs. This value is used when the Storage capacity is not given in a VM constructor. -
getTimeZone
public double getTimeZone()Description copied from interface:Vm
Gets the time zone offset, a value between [-12 and 12], in which the VM is expected to be placed (if there is aDatacenter
with enough capacity available at that timezone).To know the actual timezone where the VM is placed, check the
timezone of the Datacenter of the Host where this is VM placed
.- Specified by:
getTimeZone
in interfaceTimeZoned
- Specified by:
getTimeZone
in interfaceVm
- Returns:
- the expected timezone to place this VM
-
setTimeZone
Description copied from interface:Vm
Sets the time zone offset, a value between [-12 and 12], in which the VM is expected to be placed (if there is aDatacenter
with enough capacity available at that timezone).- Specified by:
setTimeZone
in interfaceTimeZoned
- Specified by:
setTimeZone
in interfaceVm
- Parameters:
timeZone
- the new expected time zone offset- Returns:
-