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

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 Details

    • LOGGER

      static final org.slf4j.Logger LOGGER
    • DEF_IDLE_SHUTDOWN_DEADLINE

      static final double DEF_IDLE_SHUTDOWN_DEADLINE
      The default value for the getIdleShutdownDeadline(). This value indicates that the Host won't be shutdown when becoming idle.
      See Also:
    • NULL

      static final Host NULL
      An attribute that implements the Null Object Design Pattern for Host objects.
  • Method Details

    • getDatacenter

      Datacenter getDatacenter()
      Returns:
      the Datacenter where the host is placed.
    • setDatacenter

      void setDatacenter(Datacenter datacenter)
      Sets the Datacenter where the host is placed.
      Parameters:
      datacenter - the new data center to move the host
    • isSuitableForVm

      boolean isSuitableForVm(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.
      Parameters:
      vm - the Vm to check
      Returns:
      true if is suitable for Vm, false otherwise
      See Also:
    • getSuitabilityFor

      HostSuitability getSuitabilityFor(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.
      Parameters:
      vm - the Vm to check
      Returns:
      a HostSuitability object 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:
      isFinished in interface Startable
      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

      Host setActive(boolean activate)
      Requests the Host to be powered on or off. If there is no ExecDelayable.getStartupDelay() or ExecDelayable.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 a failed host.
      See Also:
    • shutdown

      void shutdown()
      Sends a request to shut down the Host.
      Specified by:
      shutdown in interface ExecDelayable
      See Also:
    • getVmsMigratingIn

      <T extends Vm> Set<T> getVmsMigratingIn()
      Gets the list of VMs migrating into this host.
      Type Parameters:
      T - the generic type
      Returns:
      the VMs migrating in
    • hasMigratingVms

      boolean hasMigratingVms()
      Returns:
      true if there is any VM migrating in or out this host; false otherwise.
    • addMigratingInVm

      boolean addMigratingInVm(Vm vm)
      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 the getVmsMigratingIn() 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

      Set<Vm> getVmsMigratingOut()
      Returns:
      a read-only list of VMs migrating out from the Host.
    • addVmMigratingOut

      boolean addVmMigratingOut(Vm vm)
      Adds a Vm to the list of VMs migrating out this Host.
      Parameters:
      vm - the Vm to be added
      Returns:
      true if the Vm was added, false otherwise
    • removeVmMigratingOut

      boolean removeVmMigratingOut(Vm vm)
      Removes a Vm from the list of VMs migrating out this Host.
      Parameters:
      vm - the Vm to be removed
      Returns:
      true if the Vm was removed, false otherwise
    • 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:
      getTotalMipsCapacity in interface Machine<FileStorage>
      Returns:
      total MIPS capacity of Pes which are not Pe.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

      double getTotalAllocatedMipsForVm(Vm vm)
      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

      void removeMigratingInVm(Vm vm)
      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

      List<Pe> getPeList()
      Returns:
      the list of all Pes of the host, including failed PEs.
      See Also:
    • getWorkingPeList

      List<Pe> getWorkingPeList()
      Returns:
      the list of working (non-failed) Pes of the Host.
    • getBusyPeList

      List<Pe> getBusyPeList()
      Returns:
      the list of Pes of the Host that are Pe.Status.BUSY.
    • getFreePeList

      List<Pe> getFreePeList()
      Returns:
      the list of free (non-failed) Pes of the Host.
    • 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 are Pe.Status.BUSY.
    • getBusyPesPercent

      double getBusyPesPercent()
      Returns:
      the current percentage (from 0..1) of used (busy) Pes, according to the total number of PEs.
      See Also:
    • getBusyPesPercent

      double getBusyPesPercent(boolean hundredScale)
      Gets the current percentage of used (busy) Pes, according to the total 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

      Host setBwProvisioner(ResourceProvisioner bwProvisioner)
      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

      Host setRamProvisioner(ResourceProvisioner ramProvisioner)
      Sets the ram provisioner with capacity in Megabytes.
      Parameters:
      ramProvisioner - the new ram provisioner
    • getVmList

      <T extends Vm> List<T> getVmList()
      Gets a list of VMs currently assigned to the Host.
      Type Parameters:
      T - The generic type
      Returns:
      the read-only current VM list
    • getVmCreatedList

      <T extends Vm> List<T> 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

      Host setVmScheduler(VmScheduler vmScheduler)
      Sets the policy for allocation of host Pes 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:
      getFinishTime in interface Startable
      Returns:
      the last time the Host was shut down (in seconds) or -1 if the Host is active.
    • setFinishTime

      Startable setFinishTime(double shutdownTime)
      Sets the Host shut down time.
      Specified by:
      setFinishTime in interface Startable
      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

      Host setIdleShutdownDeadline(double deadline)
      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_VALUE if there is no next Cloudlet to execute
    • createVm

      HostSuitability createVm(Vm vm)
      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)
      See Also:
    • createTemporaryVm

      HostSuitability createTemporaryVm(Vm vm)
      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 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/cloudsimplus/cloudsimplus/issues/94
    • addOnStartupListener

      Host addOnStartupListener(EventListener<HostEventInfo> listener)
      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

      boolean removeOnStartupListener(EventListener<HostEventInfo> listener)
      Removes a Listener object from the OnStartup List.
      Parameters:
      listener - the Listener to remove
      Returns:
      true if the Listener was removed, false otherwise
    • addOnShutdownListener

      Host addOnShutdownListener(EventListener<HostEventInfo> listener)
      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

      boolean removeOnShutdownListener(EventListener<HostEventInfo> listener)
      Removes a Listener object from the OnShutdown List.
      Parameters:
      listener - the Listener to remove
      Returns:
      true if the Listener was removed, false otherwise
    • addOnUpdateProcessingListener

      Host addOnUpdateProcessingListener(EventListener<HostUpdatesVmsProcessingEventInfo> listener)
      Adds a listener object that will be notified every time the host updates the processing of all its VMs.
      Parameters:
      listener - the OnUpdateProcessingListener to add
      Returns:
      this Host
      See Also:
    • removeOnUpdateProcessingListener

      boolean removeOnUpdateProcessingListener(EventListener<HostUpdatesVmsProcessingEventInfo> listener)
      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

      Host setSimulation(Simulation simulation)
      Sets the CloudSimPlus instance that represents the simulation the Host is related to. Such an attribute has to be set by the Datacenter that the host belongs to.
      Parameters:
      simulation - The CloudSimPlus instance that represents the simulation the Host is related
    • getProvisioner

      ResourceProvisioner getProvisioner(Class<? extends ResourceManageable> resourceClass)
      Gets the ResourceProvisioners that manages a Host's resource such as Ram, Bandwidth and Pe.
      Parameters:
      resourceClass - the class of the resource to get its provisioner
      Returns:
      the ResourceProvisioner for 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 Datacenter.getSchedulingInterval().

      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.
      Specified by:
      getCpuUtilizationStats in interface ResourceStatsComputer<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:
      enableUtilizationStats in interface ResourceStatsComputer<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:
      getPowerModel in interface PowerAware<PowerModelHost>
      Returns:
      the PowerModelHost used by the host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.
    • setPowerModel

      PowerAware<PowerModelHost> setPowerModel(PowerModelHost powerModel)
      Sets the PowerModelHost 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 interface PowerAware<PowerModelHost>
      Parameters:
      powerModel - the PowerModelHost to set
    • setStateHistoryEnabled

      Host setStateHistoryEnabled(boolean enable)
      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

      List<Vm> getFinishedVms()
      Returns:
      the List of VMs that have finished executing.
    • getMigratableVms

      List<Vm> getMigratableVms()
      Returns:
      the list of VMs that can be migrated from the Host.
    • isLazySuitabilityEvaluation

      boolean isLazySuitabilityEvaluation()
      Checks if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such as isSuitableForVm(Vm). See setLazySuitabilityEvaluation(boolean) for important details.
      Returns:
      true if the lazy evaluation is enabled, false otherwise
    • setLazySuitabilityEvaluation

      Host setLazySuitabilityEvaluation(boolean lazySuitabilityEvaluation)
      Defines if the suitability evaluation of this Host for a given Vm is to be performed lazily by methods such as isSuitableForVm(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 calling getSuitabilityFor(Vm).
      Parameters:
      lazySuitabilityEvaluation - true to enable lazy evaluation, false to disable