Package org.cloudbus.cloudsim.hosts
Interface Host
- All Superinterfaces:
AbstractMachine<FileStorage>
,ChangeableId
,Comparable<Host>
,Identifiable
,Machine
,PowerAware<PowerModelHost>
,Resourceful
,ResourceStatsComputer<HostResourceStats>
- All Known Implementing Classes:
HostSimple
,NetworkHost
public interface Host
extends Machine, Comparable<Host>, PowerAware<PowerModelHost>, ResourceStatsComputer<HostResourceStats>
An interface to be implemented by each class that provides
Physical Machines (Hosts) features.
The interface implements the Null Object Design
Pattern in order to start avoiding
NullPointerException
when using the NULL
object instead
of attributing null
to Host
variables.- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The default value for thegetIdleShutdownDeadline()
.static final org.slf4j.Logger
static final Host
An attribute that implements the Null Object Design Pattern forHost
objects. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addMigratingInVm
(Vm vm) Try to add a VM migrating into the current host if there is enough resources for it.addOnShutdownListener
(EventListener<HostEventInfo> listener) Adds a listener object that will be notified every time the host is powered off.addOnStartupListener
(EventListener<HostEventInfo> listener) Adds a listener object that will be notified every time the host is powered on.Adds a listener object that will be notified every time the host updates the processing of all itsVMs
.boolean
addVmMigratingOut
(Vm vm) Adds aVm
to the list of VMs migrating out from the Host.createTemporaryVm
(Vm vm) Try to allocate resources to a new temporary VM in the Host.Try to allocate resources to a new VM in the Host.void
Destroys all VMs running in the host and remove them from thegetVmList()
.void
destroyTemporaryVm
(Vm vm) Destroys a temporary VM created into the Host to book resources.void
Destroys a VM running in the host and removes it from thegetVmList()
.void
Disable storing Host state history.void
Enables storing Host state history.void
Enables the data collection and computation of utilization statistics.long
Gets the total free storage available at the host in Megabytes.Gets the list of working Processing Elements (PEs) of the host, which excludes failed PEs.int
Gets the number of PEs that arePe.Status.BUSY
.double
Gets the current percentage (from 0..1) of used (busy) PEs, according to thetotal number of PEs
.double
getBusyPesPercent
(boolean hundredScale) Gets the current percentage of used (busy) PEs, according to thetotal number of PEs
.Gets the bandwidth (BW) provisioner with capacity in Megabits/s.long
Gets the current utilization of bw (in Megabits/s).double
Gets the current total utilization of CPU in MIPS, considering the usage of all its PEs.double
Gets the percentage of CPU capacity (MIPS %) requested by all running VMs at the current time.double
Gets the current percentage of CPU capacity (MIPS %) used by all running VMs.Gets machine's CPU utilization percentage statistics (between [0 and 1]).Gets the Datacenter where the host is placed.int
Gets the number of PEs that have failed.Gets the List of VMs that have finished executing.double
Gets the first time the Host was powered-on (in seconds).Gets the list of Free Processing Elements (PEs) of the host, which excludes failed PEs.int
Gets the number of PEs that are free to be used by any VM.double
Gets the deadline to shut down the Host when it becomes idle.Gets the list of migratable VMs from a given host.Gets the list of all Processing Elements (PEs) of the host, including failed PEs.Gets thePowerModelHost
used by the host to define how it consumes power.getProvisioner
(Class<? extends ResourceManageable> resourceClass) Gets the ram provisioner with capacity in Megabytes.long
Gets the current utilization of memory (in Megabytes).double
Gets the last time the Host was shut down (in seconds).Gets a read-only host state history.getSuitabilityFor
(Vm vm) Checks if the host is suitable for a Vm (if it has enough resources to attend the Vm) and the Host is not failed, providing fine-grained information about each individual Host's resource suitability.double
Gets the total allocated MIPS at the host.double
Gets the total allocated MIPS for a VM along all its PEs.double
Gets the current total amount of available MIPS at the host.double
Gets total MIPS capacity of PEs which are notPe.Status.FAILED
.double
Gets the total time the Host stayed active (powered on).double
Gets the total time the Host stayed active (powered on).double
Gets the elapsed time since the last power on.double
Gets the elapsed time in hours since the last power on.Gets a read-only list of all VMs which have been created into the host during the entire simulation.Gets as list of VMs currently assigned to the host.Gets the policy for allocation of host PEs to VMs in order to schedule VM execution.Gets the list of VMs migrating into this host.Gets a read-only list of VMs migrating out from the Host.Gets the list of working Processing Elements (PEs) of the host.int
Gets the number of PEs that are working.boolean
Checks if the Host has ever started sometime, i.e., if it was active sometime in the simulation execution.boolean
Checks if there is any VMs migrating in or out this host.boolean
isActive()
Checks if the Host is powered-on or not.boolean
isFailed()
Checks if the host is working properly or has failed.boolean
Checks if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such asisSuitableForVm(Vm)
.boolean
Checks if Host state history is being collected and stored.boolean
isSuitableForVm
(Vm vm) Checks if the host is suitable for a Vm (if it has enough resources to attend the Vm) and the Host is not failed.void
Reallocate VMs migrating into the host.void
Removes a VM migrating into this Host from the migrating-in list, so that the VM can be actually placed into the Host and the migration process finished.boolean
removeOnShutdownListener
(EventListener<HostEventInfo> listener) Removes a Listener object from the registered List.boolean
removeOnStartupListener
(EventListener<HostEventInfo> listener) Removes a Listener object from the registered List.boolean
Removes a Listener object from the registered List.boolean
Adds aVm
to the list of VMs migrating out from the Host.setActive
(boolean activate) Requests the Host to be powered on or off.setBwProvisioner
(ResourceProvisioner bwProvisioner) Sets the bandwidth (BW) provisioner with capacity in Megabits/s.void
setDatacenter
(Datacenter datacenter) Sets the Datacenter where the host is placed.boolean
setFailed
(boolean failed) Sets the Host state to "failed" or "working".setIdleShutdownDeadline
(double deadline) Sets the deadline to shutdown the Host when it becomes idle.setLazySuitabilityEvaluation
(boolean lazySuitabilityEvaluation) Defines if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such asisSuitableForVm(Vm)
.void
setPowerModel
(PowerModelHost powerModel) Sets thePowerModelHost
used by the host to define how it consumes power.setRamProvisioner
(ResourceProvisioner ramProvisioner) Sets the ram provisioner with capacity in Megabytes.void
setShutdownTime
(double shutdownTime) Sets the the Host shut down time.setSimulation
(Simulation simulation) Sets the CloudSim instance that represents the simulation the Entity belongs Such attribute has to be set by theDatacenter
that the host belongs to.setVmScheduler
(VmScheduler vmScheduler) Sets the policy for allocation of host PEs to VMs in order to schedule VM execution.double
updateProcessing
(double currentTime) Updates the processing of VMs running on this Host, that makes the processing of cloudlets inside such VMs to be updated.Methods inherited from interface org.cloudbus.cloudsim.core.AbstractMachine
getBw, getIdleInterval, getLastBusyTime, getMips, getNumberOfPes, getRam, getSimulation, getStartTime, getStorage, isIdle, isIdleEnough, setStartTime
Methods inherited from interface org.cloudbus.cloudsim.core.ChangeableId
setId
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface org.cloudbus.cloudsim.core.Identifiable
getId
Methods inherited from interface org.cloudbus.cloudsim.core.Machine
getExpectedRelativeCpuUtilization, getRelativeBwUtilization, getRelativeCpuUtilization, getRelativeMipsCapacityPercent, getRelativeRamUtilization
Methods inherited from interface org.cloudbus.cloudsim.resources.Resourceful
getResource, getResources
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER -
DEF_IDLE_SHUTDOWN_DEADLINE
static final double DEF_IDLE_SHUTDOWN_DEADLINEThe default value for thegetIdleShutdownDeadline()
. This value indicates that the Host won't be shutdown when becoming idle.- See Also:
-
NULL
An attribute that implements the Null Object Design Pattern forHost
objects.
-
-
Method Details
-
getDatacenter
Datacenter getDatacenter()Gets the Datacenter where the host is placed.- Returns:
- the data center of the host
-
setDatacenter
Sets the Datacenter where the host is placed.- Parameters:
datacenter
- the new data center to move the host
-
isSuitableForVm
Checks if the host is suitable for a Vm (if it has enough resources to attend the Vm) and the Host is not failed.- Parameters:
vm
- the Vm to check- Returns:
- true if is suitable for Vm, false otherwise
- See Also:
-
getSuitabilityFor
Checks if the host is suitable for a Vm (if it has enough resources to attend the Vm) and the Host is not failed, providing fine-grained information about each individual Host's resource suitability.- Parameters:
vm
- the Vm to check- Returns:
- a
HostSuitability
object containing indicating the Host's resources that are suitable or not for the given Vm. - See Also:
-
isActive
boolean isActive()Checks if the Host is powered-on or not.- Returns:
- true if the Host is powered-on, false otherwise.
-
hasEverStarted
boolean hasEverStarted()Checks if the Host has ever started sometime, i.e., if it was active sometime in the simulation execution.- Returns:
-
setActive
Requests the Host to be powered on or off. If there is noPowerModelHost.getStartupDelay()
orPowerModelHost.getShutDownDelay()
(which is the default), those operations will happen immediately.If the Host is set to be powered off while it has running VMs, it is simulated a scheduled shutdown, so that those VMs will finish, but new ones won't be submitted to this Host.
- Parameters:
activate
- true to power on, false to power off- Returns:
- this Host instance
- Throws:
IllegalStateException
- when trying to activate afailed
host.- See Also:
-
getVmsMigratingIn
Gets the list of VMs migrating into this host.- Type Parameters:
T
- the generic type- Returns:
- the vms migrating in
-
hasMigratingVms
boolean hasMigratingVms()Checks if there is any VMs migrating in or out this host.- Returns:
-
addMigratingInVm
Try to add a VM migrating into the current host if there is enough resources for it. In this case, the resources are allocated and the VM added to thegetVmsMigratingIn()
List. Otherwise, the VM is not added.- Parameters:
vm
- the vm- Returns:
- true if the Vm was migrated in; false if the Host doesn't have enough resources to place the Vm
-
getVmsMigratingOut
Gets a read-only list of VMs migrating out from the Host.- Returns:
-
addVmMigratingOut
Adds aVm
to the list of VMs migrating out from the Host.- Parameters:
vm
- the vm to be added- Returns:
- true if the VM wasn't into the list and was added, false otherwise
-
removeVmMigratingOut
Adds aVm
to the list of VMs migrating out from the Host.- Parameters:
vm
- the vm to be added- Returns:
-
reallocateMigratingInVms
void reallocateMigratingInVms()Reallocate VMs migrating into the host. Gets the VM in the migrating in queue and allocate them on the host. -
getTotalMipsCapacity
double getTotalMipsCapacity()Gets total MIPS capacity of PEs which are notPe.Status.FAILED
.- Specified by:
getTotalMipsCapacity
in interfaceAbstractMachine<FileStorage>
- Returns:
- the total MIPS of working PEs
-
getTotalAvailableMips
double getTotalAvailableMips()Gets the current total amount of available MIPS at the host.- Returns:
- the total available amount of MIPS
-
getTotalAllocatedMips
double getTotalAllocatedMips()Gets the total allocated MIPS at the host.- Returns:
- the total allocated amount of MIPS
-
getTotalAllocatedMipsForVm
Gets the total allocated MIPS for a VM along all its PEs.- Parameters:
vm
- the vm- Returns:
- the allocated mips for vm
-
removeMigratingInVm
Removes a VM migrating into this Host from the migrating-in list, so that the VM can be actually placed into the Host and the migration process finished.- Parameters:
vm
- the vm
-
getPeList
Gets the list of all Processing Elements (PEs) of the host, including failed PEs.- Returns:
- the list of all Host PEs
- See Also:
-
getWorkingPeList
Gets the list of working Processing Elements (PEs) of the host. It's the list of all PEs which are not FAILEd.- Returns:
- the list working (non-failed) Host PEs
-
getBusyPeList
Gets the list of working Processing Elements (PEs) of the host, which excludes failed PEs.- Returns:
- the list working (non-failed) Host PEs
-
getFreePeList
Gets the list of Free Processing Elements (PEs) of the host, which excludes failed PEs.- Returns:
- the list free (non-failed) Host PEs
-
getFreePesNumber
int getFreePesNumber()Gets the number of PEs that are free to be used by any VM.- Returns:
- the free pes number
-
getWorkingPesNumber
int getWorkingPesNumber()Gets the number of PEs that are working. That is, the number of PEs that aren't FAIL.- Returns:
- the number of working pes
-
getBusyPesNumber
int getBusyPesNumber()Gets the number of PEs that arePe.Status.BUSY
. That is, the number of PEs that aren't FAIL.- Returns:
- the number of working pes
-
getBusyPesPercent
double getBusyPesPercent()Gets the current percentage (from 0..1) of used (busy) PEs, according to thetotal number of PEs
.- Returns:
- See Also:
-
getBusyPesPercent
double getBusyPesPercent(boolean hundredScale) Gets the current percentage of used (busy) PEs, according to thetotal number of PEs
.- Parameters:
hundredScale
- if true, result is provided from 0..100 scale; otherwise, it's returned in scale from 0..1.- Returns:
- the percentage of busy PEs in the defined scale
- See Also:
-
getFailedPesNumber
int getFailedPesNumber()Gets the number of PEs that have failed.- Returns:
- the number of failed pes
-
getAvailableStorage
long getAvailableStorage()Gets the total free storage available at the host in Megabytes.- Returns:
- the free storage
-
getBwProvisioner
ResourceProvisioner getBwProvisioner()Gets the bandwidth (BW) provisioner with capacity in Megabits/s.- Returns:
- the bw provisioner
-
setBwProvisioner
Sets the bandwidth (BW) provisioner with capacity in Megabits/s.- Parameters:
bwProvisioner
- the new bw provisioner
-
getRamProvisioner
ResourceProvisioner getRamProvisioner()Gets the ram provisioner with capacity in Megabytes.- Returns:
- the ram provisioner
-
setRamProvisioner
Sets the ram provisioner with capacity in Megabytes.- Parameters:
ramProvisioner
- the new ram provisioner
-
getVmList
Gets as list of VMs currently assigned to the host.- Type Parameters:
T
- The generic type- Returns:
- the read-only current vm list
-
getVmCreatedList
Gets a read-only list of all VMs which have been created into the host during the entire simulation. This way, this method returns a historic list of created VMs, including those ones already destroyed.- Type Parameters:
T
- The generic type- Returns:
- the read-only vm created historic list
-
getVmScheduler
VmScheduler getVmScheduler()Gets the policy for allocation of host PEs to VMs in order to schedule VM execution.- Returns:
- the
VmScheduler
-
setVmScheduler
Sets the policy for allocation of host PEs to VMs in order to schedule VM execution. The host also sets itself to the given scheduler. It also sets the Host itself to the given scheduler.- Parameters:
vmScheduler
- the vm scheduler to set- Returns:
-
getFirstStartTime
double getFirstStartTime()Gets the first time the Host was powered-on (in seconds).- Returns:
- the first Host startup time or -1 if the Host has never been powered on
- See Also:
-
getShutdownTime
double getShutdownTime()Gets the last time the Host was shut down (in seconds).- Returns:
- the last shut downtime or -1 if the Host is active
-
setShutdownTime
void setShutdownTime(double shutdownTime) Sets the the Host shut down time.- Parameters:
shutdownTime
- the time to set (in seconds)- See Also:
-
getUpTime
double getUpTime()Gets the elapsed time since the last power on.- Returns:
- the elapsed time (in seconds)
- See Also:
-
getUpTimeHours
double getUpTimeHours()Gets the elapsed time in hours since the last power on.- Returns:
- the elapsed time (in hours)
- See Also:
-
getTotalUpTime
double getTotalUpTime()Gets the total time the Host stayed active (powered on). Since the Host can be powered on and off according to demand, this method returns the sum of all intervals the Host was active (in seconds).- Returns:
- the total uptime (in seconds)
- See Also:
-
getTotalUpTimeHours
double getTotalUpTimeHours()Gets the total time the Host stayed active (powered on). Since the Host can be powered on and off according to demand, this method returns the sum of all intervals the Host was active (in hours).- Returns:
- the total uptime (in hours)
- See Also:
-
getIdleShutdownDeadline
double getIdleShutdownDeadline()Gets the deadline to shut down the Host when it becomes idle. This is the time interval after the Host becoming idle that it will be shutdown.- Returns:
- the idle shutdown deadline (in seconds)
- See Also:
-
setIdleShutdownDeadline
Sets the deadline to shutdown the Host when it becomes idle. This is the time interval after the Host becoming idle that it will be shutdown.- Parameters:
deadline
- the deadline to shut down the Host after it becoming idle (in seconds). A negative value disables idle host shutdown.- Returns:
- See Also:
-
isFailed
boolean isFailed()Checks if the host is working properly or has failed.- Returns:
- true, if the host PEs have failed; false otherwise
-
setFailed
boolean setFailed(boolean failed) Sets the Host state to "failed" or "working".- Parameters:
failed
- true to set the Host to "failed", false to set to "working"- Returns:
- true if the Host status was changed, false otherwise
-
updateProcessing
double updateProcessing(double currentTime) Updates the processing of VMs running on this Host, that makes the processing of cloudlets inside such VMs to be updated.- Parameters:
currentTime
- the current time- 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
-
createVm
Try to allocate resources to a new VM in the Host.- Parameters:
vm
- Vm being started- Returns:
- a
HostSuitability
to indicate if the Vm was placed into the host or not (if the Host doesn't have enough resources to allocate the Vm)
-
destroyVm
Destroys a VM running in the host and removes it from thegetVmList()
. If the VM was not created yet, this method has no effect.- Parameters:
vm
- the VM to be destroyed
-
createTemporaryVm
Try to allocate resources to a new temporary VM in the Host. The method is used only to book resources for a given VM. For instance, if Hosts are being chosen to migrate a set of VMs, when a Host is selected for a given VM, using this method, the resources are reserved and then, when the next VM is selected for the same Host, the reserved resources already were reduced from the available amount. This way, if it was possible to place just one Vm into that Host, with the booking, no other VM will be selected to that Host.- Parameters:
vm
- Vm being started- Returns:
- a
HostSuitability
to indicate if the Vm was placed into the host or not (if the Host doesn't have enough resources to allocate the Vm) TODO: https://github.com/manoelcampos/cloudsim-plus/issues/94
-
destroyTemporaryVm
Destroys a temporary VM created into the Host to book resources.- Parameters:
vm
- the VM- See Also:
-
destroyAllVms
void destroyAllVms()Destroys all VMs running in the host and remove them from thegetVmList()
. -
addOnStartupListener
Adds a listener object that will be notified every time the host is powered on.- Parameters:
listener
- the Listener to add- Returns:
-
removeOnStartupListener
Removes a Listener object from the registered List.- Parameters:
listener
- the Listener to remove- Returns:
- true if the Listener was removed, false otherwise
-
addOnShutdownListener
Adds a listener object that will be notified every time the host is powered off.- Parameters:
listener
- the Listener to add- Returns:
-
removeOnShutdownListener
Removes a Listener object from the registered List.- Parameters:
listener
- the Listener to remove- Returns:
- true if the Listener was removed, false otherwise
-
addOnUpdateProcessingListener
Adds a listener object that will be notified every time the host updates the processing of all itsVMs
.- Parameters:
listener
- the OnUpdateProcessingListener to add- Returns:
- See Also:
-
removeOnUpdateProcessingListener
Removes a Listener object from the registered List.- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
- See Also:
-
setSimulation
Sets the CloudSim instance that represents the simulation the Entity belongs Such attribute has to be set by theDatacenter
that the host belongs to.- Parameters:
simulation
- The CloudSim instance that represents the simulation the Entity belongs- Returns:
-
getProvisioner
- Parameters:
resourceClass
- the class of the resource to get its provisioner- Returns:
- the
ResourceProvisioner
for the given resource class
-
getCpuPercentUtilization
double getCpuPercentUtilization()Gets the current percentage of CPU capacity (MIPS %) used by all running VMs. It represents the actual percentage of MIPS allocated.- Returns:
- total CPU utilization percentage (between [0 and 1]) for the current time
-
getCpuPercentRequested
double getCpuPercentRequested()Gets the percentage of CPU capacity (MIPS %) requested by all running VMs at the current time. It represents the percentage of MIPS requested, which may be higher than the percentage used (allocated) due to lack of capacity.- Returns:
- the percentage (between [0 and 1]) of CPU capacity requested
-
getCpuUtilizationStats
HostResourceStats getCpuUtilizationStats()Gets machine's CPU utilization percentage statistics (between [0 and 1]).WARNING: You need to enable the data collection and computation of statistics by calling
ResourceStatsComputer.enableUtilizationStats()
.The time interval in which utilization is collected is defined by the
It uses the utilization statistics from its VMs to provide the overall Host's CPU utilization. However, for this method to return any data, you need to enable the statistics computation for every VM it owns.Datacenter.getSchedulingInterval()
.- Specified by:
getCpuUtilizationStats
in interfaceResourceStatsComputer<HostResourceStats>
- Returns:
-
enableUtilizationStats
void enableUtilizationStats()Enables the data collection and computation of utilization statistics. It iterates over all existing VMs enabling the statistics computation on every one. But keep in mind that when a Host is created, it has no VM. Therefore, you need to call this method for every VM if you are enabling the computation before the simulation starts and VM placement is performed.- Specified by:
enableUtilizationStats
in interfaceResourceStatsComputer<HostResourceStats>
- See Also:
-
getCpuMipsUtilization
double getCpuMipsUtilization()Gets the current total utilization of CPU in MIPS, considering the usage of all its PEs.- Returns:
-
getBwUtilization
long getBwUtilization()Gets the current utilization of bw (in Megabits/s).- Returns:
-
getRamUtilization
long getRamUtilization()Gets the current utilization of memory (in Megabytes).- Returns:
-
getPowerModel
PowerModelHost getPowerModel()Gets thePowerModelHost
used by the host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.- Specified by:
getPowerModel
in interfacePowerAware<PowerModelHost>
- Returns:
- the Host's
PowerModelHost
-
setPowerModel
Sets thePowerModelHost
used by the host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.- Specified by:
setPowerModel
in interfacePowerAware<PowerModelHost>
- Parameters:
powerModel
- thePowerModelHost
to set
-
enableStateHistory
void enableStateHistory()Enables storing Host state history.- See Also:
-
disableStateHistory
void disableStateHistory()Disable storing Host state history.- See Also:
-
isStateHistoryEnabled
boolean isStateHistoryEnabled()Checks if Host state history is being collected and stored.- Returns:
-
getStateHistory
List<HostStateHistoryEntry> getStateHistory()Gets a read-only host state history. This List is just populated ifisStateHistoryEnabled()
- Returns:
- the state history
- See Also:
-
getFinishedVms
Gets the List of VMs that have finished executing.- Returns:
-
getMigratableVms
Gets the list of migratable VMs from a given host.- Returns:
- the list of migratable VMs
-
isLazySuitabilityEvaluation
boolean isLazySuitabilityEvaluation()Checks if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such asisSuitableForVm(Vm)
. It means that the method will return as soon as some resource requirement is not met and the suitability for other VM requirements is not evaluated. This laziness improves performance but provides less information when callinggetSuitabilityFor(Vm)
.- Returns:
- true if the lazy evaluation is enabled, false otherwise
-
setLazySuitabilityEvaluation
Defines if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such asisSuitableForVm(Vm)
. It means that the method will return as soon as some resource requirement is not met and the suitability for other VM requirements is not evaluated. This laziness improves performance but provides less information when callinggetSuitabilityFor(Vm)
.
-