Interface Host
- All Superinterfaces:
ChangeableId,Comparable<Host>,ExecDelayable,Identifiable,Machine<FileStorage>,PhysicalMachine,PowerAware<PowerModelHost>,Resourceful,ResourceStatsComputer<HostResourceStats>,Startable
- All Known Implementing Classes:
HostAbstract,HostSimple,NetworkHost
public interface Host
extends PhysicalMachine, Comparable<Host>, PowerAware<PowerModelHost>, ResourceStatsComputer<HostResourceStats>
An interface to be implemented by each class that provides
Physical Machines (Hosts) features.
- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe default value for thegetIdleShutdownDeadline().static final org.slf4j.Loggerstatic final HostAn attribute that implements the Null Object Design Pattern forHostobjects.Fields inherited from interface org.cloudsimplus.core.Startable
NOT_ASSIGNED -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddMigratingInVm(Vm vm) Try to add a Vm migrating into the current Host if there are 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.booleanaddVmMigratingOut(Vm vm) Adds aVmto the list of VMs migrating out this 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.voidEnables the data collection and computation of utilization statistics.longintdoubledoublegetBusyPesPercent(boolean hundredScale) Gets the current percentage of used (busy)Pes, according to thetotal number of PEs.longdoubledoubledoubleGets machine's CPU utilization percentage statistics (between [0 and 1]).intdoubledoubleintdoubleReturns the deadline to shut down the Host (in seconds) when it becomes idle.getProvisioner(Class<? extends ResourceManageable> resourceClass) longgetSuitabilityFor(Vm vm) Checks if the host is suitable for a Vm (if it has enough resources to meet the Vm requirements) and the Host has not failed, providing fine-grained information about the suitability of each Host resource.doubledoubleReturns the total allocated MIPS for a VM across all its PEs.doubledoubledoubleReturns the total time (in seconds) the Host stayed active (powered on).doubleReturns the total time (in hours) the Host stayed active (powered on).doubledoubleGets a read-only list of all VMs that have been created into the Host during the entire simulation.Gets a list of VMs currently assigned to the Host.Gets the list of VMs migrating into this host.intbooleanbooleanbooleanisActive()booleanisFailed()Checks if the host has failed or is working properly.booleanbooleanChecks if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such asisSuitableForVm(Vm).booleanbooleanisSuitableForVm(Vm vm) Checks if the Host is suitable for a Vm (if it has enough resources to meet the Vm requirements) and the Host has not failed.voidReallocate VMs migrating into this Host.voidRemoves 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.booleanremoveOnShutdownListener(EventListener<HostEventInfo> listener) Removes a Listener object from the OnShutdown List.booleanremoveOnStartupListener(EventListener<HostEventInfo> listener) Removes a Listener object from the OnStartup List.booleanRemoves a Listener object from the OnUpdateProcessing List.booleanRemoves aVmfrom the list of VMs migrating out this 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.voidsetDatacenter(Datacenter datacenter) Sets theDatacenterwhere the host is placed.booleansetFailed(boolean failed) Sets the Host state to "failed" or "working".setFinishTime(double shutdownTime) Sets the Host shut down time.setIdleShutdownDeadline(double deadline) Sets the deadline to shut down the Host (in seconds) 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).setPowerModel(PowerModelHost powerModel) Sets thePowerModelHostused by the Host to define how it consumes power.setRamProvisioner(ResourceProvisioner ramProvisioner) Sets the ram provisioner with capacity in Megabytes.setSimulation(Simulation simulation) Sets theCloudSimPlusinstance that represents the simulation the Host is related to.setStateHistoryEnabled(boolean enable) Enables or disables the storage of Host state history.setVmScheduler(VmScheduler vmScheduler) Sets the policy for allocation of hostPes to VMs to schedule VM execution.voidshutdown()Sends a request to shut down the Host.doubleupdateProcessing(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.cloudsimplus.core.ChangeableId
setIdMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.cloudsimplus.core.ExecDelayable
getRemainingStartupTime, getShutdownBeginTime, getShutDownDelay, getStartupCompletionTime, getStartupDelay, isShutDownDelayed, isShuttingDown, isStartingUp, isStartupDelayed, setShutdownBeginTime, setShutDownDelay, setStartupDelayMethods inherited from interface org.cloudsimplus.core.Identifiable
getIdMethods inherited from interface org.cloudsimplus.core.Machine
getBw, getIdleInterval, getLastBusyTime, getMips, getPesNumber, getRam, getSimulation, getStorage, isIdle, isIdleEnoughMethods inherited from interface org.cloudsimplus.core.PhysicalMachine
getExpectedRelativeCpuUtilization, getRelativeBwUtilization, getRelativeCpuUtilization, getRelativeMipsCapacityPercent, getRelativeRamUtilizationMethods inherited from interface org.cloudsimplus.resources.Resourceful
getResource, getResourcesMethods inherited from interface org.cloudsimplus.core.Startable
getStartTime, getTotalExecutionTime, hasStarted, setLastBusyTime, setStartTime
-
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
-
-
Method Details
-
getDatacenter
Datacenter getDatacenter()- Returns:
- the
Datacenterwhere the host is placed.
-
setDatacenter
Sets theDatacenterwhere 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 meet the Vm requirements) and the Host has 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 meet the Vm requirements) and the Host has not failed, providing fine-grained information about the suitability of each Host resource.- Parameters:
vm- the Vm to check- Returns:
- a
HostSuitabilityobject indicating the Host's resources that are suitable or not for the given Vm. - See Also:
-
isActive
boolean isActive()- Returns:
- true if the Host is powered-on, false otherwise.
- See Also:
-
isFinished
boolean isFinished()- Specified by:
isFinishedin interfaceStartable- Returns:
- true if the host is powered-off, false otherwise
- See Also:
-
hasEverStarted
boolean hasEverStarted()- Returns:
- true if the Host has ever started sometime, i.e., if it was active sometime in the simulation execution; false otherwise.
-
setActive
Requests the Host to be powered on or off. If there is noExecDelayable.getStartupDelay()orExecDelayable.getShutDownDelay()(which is the default), those operations will happen immediately.If the Host is set to be powered off while it has VMs running, 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 afailedhost.- See Also:
-
shutdown
void shutdown()Sends a request to shut down the Host.- Specified by:
shutdownin interfaceExecDelayable- See Also:
-
getVmsMigratingIn
-
hasMigratingVms
boolean hasMigratingVms()- Returns:
- true if there is any VM migrating in or out this host; false otherwise.
-
addMigratingInVm
Try to add a Vm migrating into the current Host if there are enough resources for it. In this case, the resources are allocated and the Vm is added to thegetVmsMigratingIn()List. Otherwise, the Vm is not added.- Parameters:
vm- the Vm to add to the migrating-in list- Returns:
- true if the Vm was migrated in; false if the Host doesn't have enough resources to place the Vm
-
getVmsMigratingOut
-
addVmMigratingOut
-
removeVmMigratingOut
-
reallocateMigratingInVms
void reallocateMigratingInVms()Reallocate VMs migrating into this Host. Gets the VMs in the migrating-in queue and allocates them on the Host. -
getTotalMipsCapacity
double getTotalMipsCapacity()- Specified by:
getTotalMipsCapacityin interfaceMachine<FileStorage>- Returns:
- total MIPS capacity of
Pes which are notPe.Status.FAILED.
-
getTotalAvailableMips
double getTotalAvailableMips()- Returns:
- the current total amount of available MIPS at the Host.
-
getTotalAllocatedMips
double getTotalAllocatedMips()- Returns:
- the total allocated MIPS at the Host.
-
getTotalAllocatedMipsForVm
Returns the total allocated MIPS for a VM across all its PEs.- Parameters:
vm- the Vm to get its total allocated MIPS- Returns:
- the total allocated MIPS for a VM across all its PEs
-
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 to remove
-
getPeList
-
getWorkingPeList
-
getBusyPeList
- Returns:
- the list of
Pes of the Host that arePe.Status.BUSY.
-
getFreePeList
-
getFreePesNumber
int getFreePesNumber()- Returns:
- the number of
Pes that are free to be used by any VM.
-
getWorkingPesNumber
int getWorkingPesNumber()- Returns:
- the number of
Pes that are working (non-failed).
-
getBusyPesNumber
int getBusyPesNumber()- Returns:
- the number of
Pes that arePe.Status.BUSY.
-
getBusyPesPercent
double getBusyPesPercent()- Returns:
- the current percentage (from 0..1) of used (busy)
Pes, according to thetotal number of PEs. - See Also:
-
getBusyPesPercent
double getBusyPesPercent(boolean hundredScale) Gets the current percentage of used (busy)Pes, according to thetotal number of PEs.- Parameters:
hundredScale- true for getting the return in the 0..100 scale; false for the 0..1 scale.- Returns:
- the percentage of busy PEs in the defined scale (according to the hundredScale parameter).
- See Also:
-
getFailedPesNumber
int getFailedPesNumber()- Returns:
- the number of
Pes that have failed.
-
getAvailableStorage
long getAvailableStorage()- Returns:
- the total free storage available at the Host in Megabytes.
-
getBwProvisioner
ResourceProvisioner getBwProvisioner()- Returns:
- the bandwidth (BW) provisioner with capacity in Megabits/s.
-
setBwProvisioner
Sets the bandwidth (BW) provisioner with capacity in Megabits/s.- Parameters:
bwProvisioner- the new bw provisioner
-
getRamProvisioner
ResourceProvisioner getRamProvisioner()- Returns:
- the ram provisioner with capacity in Megabytes.
-
setRamProvisioner
Sets the ram provisioner with capacity in Megabytes.- Parameters:
ramProvisioner- the new ram provisioner
-
getVmList
-
getVmCreatedList
Gets a read-only list of all VMs that have been created into the Host during the entire simulation. This way, this method returns a historic list of created VMs, including those already destroyed.- Type Parameters:
T- The Vm generic type- Returns:
- the read-only created VM historic list
-
getVmScheduler
VmScheduler getVmScheduler()- Returns:
- the policy for allocation of host
Pes to VMs to schedule VM execution.
-
setVmScheduler
Sets the policy for allocation of hostPes to VMs 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:
- this Host
-
getFirstStartTime
double getFirstStartTime()- Returns:
- the first Host startup time (in seconds) or -1 if the Host has never been powered on.
- See Also:
-
getFinishTime
double getFinishTime()- Specified by:
getFinishTimein interfaceStartable- Returns:
- the last time the Host was shut down (in seconds) or -1 if the Host is active.
-
setFinishTime
Sets the Host shut down time.- Specified by:
setFinishTimein interfaceStartable- Parameters:
shutdownTime- the time to set (in seconds)- Returns:
- this entity
- See Also:
-
getUpTime
double getUpTime()- Returns:
- the elapsed time (in seconds) since the last power on.
- See Also:
-
getUpTimeHours
double getUpTimeHours()- Returns:
- the elapsed time (in hours) since the last power on.
- See Also:
-
getTotalUpTime
double getTotalUpTime()Returns the total time (in seconds) the Host stayed active (powered on). Since the Host can be powered on and off according to the demand, this method returns the sum of all intervals the Host was active.- Returns:
- the total time (in seconds) the Host stayed active (powered on)
- See Also:
-
getTotalUpTimeHours
double getTotalUpTimeHours()Returns the total time (in hours) the Host stayed active (powered on). Since the Host can be powered on and off according to the demand, this method returns the sum of all intervals the Host was active.- Returns:
- the total time (in hours) the Host stayed active (powered on)
- See Also:
-
getIdleShutdownDeadline
double getIdleShutdownDeadline()Returns the deadline to shut down the Host (in seconds) when it becomes idle. This is the time interval after the Host becomes idle that it will be shut down.- Returns:
- the deadline to shut down the Host (in seconds) when it becomes idle
- See Also:
-
setIdleShutdownDeadline
Sets the deadline to shut down the Host (in seconds) when it becomes idle. This is the time interval after the Host becomes idle that it will be shut down.- Parameters:
deadline- the deadline to shut down the Host after it becomes idle (in seconds). A negative value disables idle host shutdown.- See Also:
-
isFailed
boolean isFailed()Checks if the host has failed or is working properly.- 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_VALUEif 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
HostSuitabilityto indicate if the Vm was placed into the host or not (if the Host doesn't have enough resources to allocate the Vm) - See Also:
-
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. 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, - then, when the next Vm is selected for the same Host, the previous reserved resources were already 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 it.- Parameters:
vm- Vm being started- Returns:
- a
HostSuitabilityto 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/cloudsimplus/cloudsimplus/issues/94
-
addOnStartupListener
Adds a listener object that will be notified every time the host is powered on.- Parameters:
listener- the Listener to add- Returns:
- this Host
-
removeOnStartupListener
Removes a Listener object from the OnStartup 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:
- this Host
-
removeOnShutdownListener
Removes a Listener object from the OnShutdown 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:
- this Host
- See Also:
-
removeOnUpdateProcessingListener
Removes a Listener object from the OnUpdateProcessing List.- Parameters:
listener- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
- See Also:
-
setSimulation
Sets theCloudSimPlusinstance that represents the simulation the Host is related to. Such an attribute has to be set by theDatacenterthat the host belongs to.- Parameters:
simulation- The CloudSimPlus instance that represents the simulation the Host is related
-
getProvisioner
- Parameters:
resourceClass- the class of the resource to get its provisioner- Returns:
- the
ResourceProvisionerfor the given resource class
-
getCpuPercentUtilization
double getCpuPercentUtilization()- Returns:
- the current percentage (between [0 and 1]) of CPU capacity (MIPS) used by all running VMs. It represents the actual percentage of MIPS allocated.
-
getCpuPercentRequested
double getCpuPercentRequested()- Returns:
- the percentage (between [0 and 1]) 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.
-
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 relies on 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:
getCpuUtilizationStatsin interfaceResourceStatsComputer<HostResourceStats>- Returns:
- an object containing the statistics
- See Also:
-
enableUtilizationStats
void enableUtilizationStats()Enables the data collection and computation of utilization statistics. It iterates over all existing VMs, enabling the statistics computation on everyone. Keep in mind that when a Host is created, it has no VMs. 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:
enableUtilizationStatsin interfaceResourceStatsComputer<HostResourceStats>- See Also:
-
getCpuMipsUtilization
double getCpuMipsUtilization()- Returns:
- the current total utilization of CPU in MIPS, considering the usage of all its PEs.
-
getBwUtilization
long getBwUtilization()- Returns:
- the current utilization of bw (in Megabits/s).
-
getRamUtilization
long getRamUtilization()- Returns:
- the current utilization of memory (in Megabytes).
-
getPowerModel
PowerModelHost getPowerModel()- Specified by:
getPowerModelin interfacePowerAware<PowerModelHost>- Returns:
- the
PowerModelHostused by the host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.
-
setPowerModel
Sets thePowerModelHostused by the Host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.- Specified by:
setPowerModelin interfacePowerAware<PowerModelHost>- Parameters:
powerModel- thePowerModelHostto set
-
setStateHistoryEnabled
Enables or disables the storage of Host state history.- Parameters:
enable- true to enable, false to disable- See Also:
-
isStateHistoryEnabled
boolean isStateHistoryEnabled()- Returns:
- if Host state history is being collected and stored.
-
getStateHistory
List<HostStateHistoryEntry> getStateHistory()- Returns:
- a read-only Host state history.
This List is just populated if
isStateHistoryEnabled() - See Also:
-
getFinishedVms
-
getMigratableVms
-
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). SeesetLazySuitabilityEvaluation(boolean)for important details.- 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. This way, the suitability for other VM requirements is not evaluated. This laziness improves performance but provides less information when callinggetSuitabilityFor(Vm).- Parameters:
lazySuitabilityEvaluation- true to enable lazy evaluation, false to disable
-