Package org.cloudbus.cloudsim.vms
Class VmUtilizationHistory
java.lang.Object
org.cloudbus.cloudsim.vms.VmUtilizationHistory
- All Implemented Interfaces:
UtilizationHistory
public class VmUtilizationHistory extends java.lang.Object implements UtilizationHistory
Stores resource utilization data for a specific
Vm
.- Since:
- CloudSim Plus 1.4
- Author:
- Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
-
Constructor Summary
Constructors Constructor Description VmUtilizationHistory(Vm vm)
Instantiates the class to store resource utilization history for a specificVm
.VmUtilizationHistory(Vm vm, boolean enabled)
Instantiates the class to store resource utilization history for a specificVm
. -
Method Summary
Modifier and Type Method Description void
addUtilizationHistory(double time)
Adds a CPU utilization percentage history value related to the current simulation time, to the beginning of the History List.void
disable()
Disables the history to avoid utilization data to be added to it.void
enable()
Enables the history so that utilization data can be added to it.java.util.SortedMap<java.lang.Double,java.lang.Double>
getHistory()
Gets a read-only CPU utilization percentage history map where each key is the time the utilization was collected and each value is the utilization percentage (between [0 and 1]).double
getHostCpuUtilization(double time)
Computes the relative percentage of the CPU the VM is using from the Host's total MIPS Capacity.int
getMaxHistoryEntries()
Gets the maximum number of entries to store in the history.double
getUtilizationMad()
Gets the utilization Median Absolute Deviation (MAD) in MIPS.double
getUtilizationMean()
Gets the utilization mean in MIPS.double
getUtilizationVariance()
Gets the utilization variance in MIPS.Vm
getVm()
boolean
isEnabled()
Checks if the object is enabled to add data to the history.double
powerConsumption(double time)
Computes the amount of power the VM is using, relative to the total Host's power consumption (in watt-sec).void
setMaxHistoryEntries(int maxHistoryEntries)
Sets the maximum number of entries to store in the history.
-
Constructor Details
-
VmUtilizationHistory
Instantiates the class to store resource utilization history for a specificVm
.- Parameters:
vm
- the vm to instantiates the object to store utilization historyenabled
- true if the history must be enabled by default, enabling usage history to be collected and stored; false if it must be disabled to avoid storing any history, in order to reduce memory usage
-
VmUtilizationHistory
Instantiates the class to store resource utilization history for a specificVm
.- Parameters:
vm
- the vm to instantiates the object to store utilization history
-
-
Method Details
-
getUtilizationMad
public double getUtilizationMad()Description copied from interface:UtilizationHistory
Gets the utilization Median Absolute Deviation (MAD) in MIPS.- Specified by:
getUtilizationMad
in interfaceUtilizationHistory
- Returns:
-
getUtilizationMean
public double getUtilizationMean()Description copied from interface:UtilizationHistory
Gets the utilization mean in MIPS.- Specified by:
getUtilizationMean
in interfaceUtilizationHistory
- Returns:
-
getUtilizationVariance
public double getUtilizationVariance()Description copied from interface:UtilizationHistory
Gets the utilization variance in MIPS.- Specified by:
getUtilizationVariance
in interfaceUtilizationHistory
- Returns:
- the utilization variance in MIPS
-
addUtilizationHistory
public void addUtilizationHistory(double time)Description copied from interface:UtilizationHistory
Adds a CPU utilization percentage history value related to the current simulation time, to the beginning of the History List. The value is added only if the utilization historyUtilizationHistory.isEnabled()
.- Specified by:
addUtilizationHistory
in interfaceUtilizationHistory
- Parameters:
time
- the current simulation time
-
getHistory
public java.util.SortedMap<java.lang.Double,java.lang.Double> getHistory()Description copied from interface:UtilizationHistory
Gets a read-only CPU utilization percentage history map where each key is the time the utilization was collected and each value is the utilization percentage (between [0 and 1]). There will be at least one entry for each time multiple of theDatacenter.getSchedulingInterval()
. This way, it's required to set a Datacenter scheduling interval with the desired value.- Specified by:
getHistory
in interfaceUtilizationHistory
- Returns:
-
powerConsumption
public double powerConsumption(double time)Description copied from interface:UtilizationHistory
Computes the amount of power the VM is using, relative to the total Host's power consumption (in watt-sec).- Specified by:
powerConsumption
in interfaceUtilizationHistory
- Parameters:
time
- the time to get the VM power consumption- Returns:
- the relative VM power consumption in watt-sec
-
getHostCpuUtilization
public double getHostCpuUtilization(double time)Description copied from interface:UtilizationHistory
Computes the relative percentage of the CPU the VM is using from the Host's total MIPS Capacity. If the capacity is 1000 MIPS and the VM is using 250 MIPS, it's equivalent to 25% of the Host's capacity.This method uses the historical data to compute the relative CPU utilization, allowing it to be called after the simulation finishes. It's different from the
Vm.getHostCpuUtilization(double)
that can be called only when the simulation is running.- Specified by:
getHostCpuUtilization
in interfaceUtilizationHistory
- Parameters:
time
- the time to get the relative VM CPU utilization- Returns:
- the relative VM CPU usage percent (from 0 to 1)
-
isEnabled
public boolean isEnabled()Description copied from interface:UtilizationHistory
Checks if the object is enabled to add data to the history.- Specified by:
isEnabled
in interfaceUtilizationHistory
- Returns:
-
enable
public void enable()Description copied from interface:UtilizationHistory
Enables the history so that utilization data can be added to it.- Specified by:
enable
in interfaceUtilizationHistory
-
disable
public void disable()Description copied from interface:UtilizationHistory
Disables the history to avoid utilization data to be added to it. That allows to reduce memory usage since no utilization data will be collected.- Specified by:
disable
in interfaceUtilizationHistory
-
getMaxHistoryEntries
public int getMaxHistoryEntries()Description copied from interface:UtilizationHistory
Gets the maximum number of entries to store in the history.- Specified by:
getMaxHistoryEntries
in interfaceUtilizationHistory
- Returns:
-
setMaxHistoryEntries
public void setMaxHistoryEntries(int maxHistoryEntries)Description copied from interface:UtilizationHistory
Sets the maximum number of entries to store in the history.- Specified by:
setMaxHistoryEntries
in interfaceUtilizationHistory
- Parameters:
maxHistoryEntries
- the value to set
-
getVm
- Specified by:
getVm
in interfaceUtilizationHistory
-