Interface Host
-
- All Superinterfaces:
ChangeableId
,Comparable<Host>
,Identifiable
,Machine
,Resourceful
- All Known Implementing Classes:
HostSimple
,NetworkHost
public interface Host extends Machine, Comparable<Host>
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 avoidingNullPointerException
when using theNULL
object instead of attributingnull
toHost
variables.- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addMigratingInVm(Vm vm)
Try to add a VM migrating into the current host if there is enough resources for it.Host
addOnUpdateProcessingListener(EventListener<HostUpdatesVmsProcessingEventInfo> listener)
Adds a listener object that will be notified every time when the host updates the processing of all itsVMs
.boolean
addVmMigratingOut(Vm vm)
Adds aVm
to the list of VMs migrating out from the Host.boolean
createTemporaryVm(Vm vm)
Try to allocate resources to a new temporary VM in the Host.boolean
createVm(Vm vm)
Try to allocate resources to a new VM in the Host.void
deallocatePesForVm(Vm vm)
Releases PEs allocated to a VM.void
destroyAllVms()
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
destroyVm(Vm vm)
Destroys a VM running in the host and removes it from thegetVmList()
.void
disableStateHistory()
Disable storing Host state history.void
enableStateHistory()
Enables storing Host state history.List<Double>
getAllocatedMipsForVm(Vm vm)
Gets the MIPS share of each Pe that is allocated to a given VM.double
getAvailableMips()
Gets the current amount of available MIPS at the host.long
getAvailableStorage()
Gets the total free storage available at the host in Megabytes.List<Pe>
getBuzyPeList()
Gets the list of working Processing Elements (PEs) of the host, which excludes failed PEs.ResourceProvisioner
getBwProvisioner()
Gets the bandwidth (BW) provisioner with capacity in Megabits/s.Datacenter
getDatacenter()
Gets the Datacenter where the host is placed.List<Vm>
getFinishedVms()
Gets the List of VMs that have finished executing.List<Pe>
getFreePeList()
Gets the list of Free Processing Elements (PEs) of the host, which excludes failed PEs.double
getMaxAvailableMips()
Returns the maximum available MIPS among all the PEs of the host.List<Vm>
getMigratableVms()
Gets the list of migratable VMs from a given host.long
getNumberOfFailedPes()
Gets the number of PEs that have failed.int
getNumberOfFreePes()
Gets the free pes number.long
getNumberOfWorkingPes()
Gets the number of PEs that are working.List<Pe>
getPeList()
Gets the list of all Processing Elements (PEs) of the host, including failed PEs.PowerModel
getPowerModel()
Gets thePowerModel
used by the host to define how it consumes power.double
getPreviousUtilizationOfCpu()
ResourceProvisioner
getProvisioner(Class<? extends ResourceManageable> resourceClass)
ResourceProvisioner
getRamProvisioner()
Gets the ram provisioner with capacity in Megabytes.double
getShutdownTime()
Gets the time the Host shut down.double
getStartTime()
Gets the time the Host was powered-on (in seconds).List<HostStateHistoryEntry>
getStateHistory()
Gets a read-only host state history.double
getTotalAllocatedMipsForVm(Vm vm)
Gets the total allocated MIPS for a VM along all its PEs.double
getTotalMipsCapacity()
Gets total MIPS capacity of PEs which are notPe.Status.FAILED
.SortedMap<Double,DoubleSummaryStatistics>
getUtilizationHistory()
Gets a map containing the host CPU utilization percentage history (between [0 and 1]), based on its VM utilization history.SortedMap<Double,Double>
getUtilizationHistorySum()
Gets a map containing the host CPU utilization percentage history (between [0 and 1]), based on its VM utilization history.long
getUtilizationOfBw()
Gets the current utilization of bw (in absolute values).double
getUtilizationOfCpu()
Gets current utilization of CPU in percentage (between [0 and 1]), considering the usage of all its PEs..double
getUtilizationOfCpuMips()
Gets the current total utilization of CPU in MIPS, considering the usage of all its PEs.long
getUtilizationOfRam()
Gets the current utilization of memory (in absolute values).Vm
getVm(int vmId, int brokerId)
Gets a VM by its id and user.<T extends Vm>
List<T>getVmCreatedList()
Gets a read-only list of all VMs which have been created into the host during the entire simulation.<T extends Vm>
List<T>getVmList()
Gets a read-only list of VMs currently assigned to the host.VmScheduler
getVmScheduler()
Gets the policy for allocation of host PEs to VMs in order to schedule VM execution.<T extends Vm>
Set<T>getVmsMigratingIn()
Gets the list of VMs migrating into this host.Set<Vm>
getVmsMigratingOut()
Gets a read-only list of VMs migrating out from the Host.List<Pe>
getWorkingPeList()
Gets the list of working Processing Elements (PEs) of the 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
isStateHistoryEnabled()
Checks if Host state history is being collected and stored.boolean
isSuitableForVm(Vm vm)
Checks if the host is active and is suitable for vm (if it has enough resources to attend the VM).void
reallocateMigratingInVms()
Reallocate VMs migrating into the host.void
removeMigratingInVm(Vm vm)
Removes a migrating in vm.boolean
removeOnUpdateProcessingListener(EventListener<HostUpdatesVmsProcessingEventInfo> listener)
Removes a listener object from the OnUpdateProcessingListener List.boolean
removeVmMigratingIn(Vm vm)
Adds aVm
to the list of VMs migrating into the Host.boolean
removeVmMigratingOut(Vm vm)
Adds aVm
to the list of VMs migrating out from the Host.Host
setActive(boolean active)
Sets the powered state of the Host, to indicate if it's powered on or off.Host
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".Host
setPowerModel(PowerModel powerModel)
Sets thePowerModel
used by the host to define how it consumes power.Host
setRamProvisioner(ResourceProvisioner ramProvisioner)
Sets the ram provisioner with capacity in Megabytes.void
setShutdownTime(double shutdownTime)
Sets the time the Host shut down.Host
setSimulation(Simulation simulation)
Sets the CloudSim instance that represents the simulation the Entity is related to.void
setStartTime(double startTime)
Sets the time the Host was powered-on.Host
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.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
getBw, getMips, getNumberOfPes, getRam, getSimulation, getStorage
-
Methods inherited from interface org.cloudbus.cloudsim.resources.Resourceful
getResource, getResources
-
-
-
-
Method Detail
-
getDatacenter
Datacenter getDatacenter()
Gets the Datacenter where the host is placed.- Returns:
- the data center of the host
-
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 active and is suitable for vm (if it has enough resources to attend the VM).- Parameters:
vm
- the vm to check- Returns:
- true if is suitable for vm, false otherwise
-
isActive
boolean isActive()
Checks if the Host is powered-on or not.- Returns:
- true if the Host is powered-on, false otherwise.
-
setActive
Host setActive(boolean active)
Sets the powered state of the Host, to indicate if it's powered on or off. When a Host is powered off, no VMs will be submitted to it.If it is set to powered off while VMs are running inside it, it is simulated a scheduled shutdown, so that, all running VMs will finish, but not more VMs will be submitted to this Host.
- Parameters:
active
- true to set the Host as powered on, false as powered off- Returns:
-
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
-
addMigratingInVm
boolean addMigratingInVm(Vm vm)
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
Set<Vm> getVmsMigratingOut()
Gets a read-only list of VMs migrating out from the Host.- Returns:
-
addVmMigratingOut
boolean addVmMigratingOut(Vm vm)
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
-
removeVmMigratingIn
boolean removeVmMigratingIn(Vm vm)
Adds aVm
to the list of VMs migrating into the Host.- Parameters:
vm
- the vm to be added- Returns:
-
removeVmMigratingOut
boolean removeVmMigratingOut(Vm vm)
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 interfaceMachine
- Returns:
- the total MIPS of working PEs
-
removeMigratingInVm
void removeMigratingInVm(Vm vm)
Removes a migrating in vm.- Parameters:
vm
- the vm
-
deallocatePesForVm
void deallocatePesForVm(Vm vm)
Releases PEs allocated to a VM.- Parameters:
vm
- the vm
-
getAllocatedMipsForVm
List<Double> getAllocatedMipsForVm(Vm vm)
Gets the MIPS share of each Pe that is allocated to a given VM.- Parameters:
vm
- the vm- Returns:
- an array containing the amount of MIPS of each pe that is available to the VM
-
getTotalAllocatedMipsForVm
double getTotalAllocatedMipsForVm(Vm vm)
Gets the total allocated MIPS for a VM along all its PEs.- Parameters:
vm
- the vm- Returns:
- the allocated mips for vm
-
getPeList
List<Pe> 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()
-
getWorkingPeList
List<Pe> 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
-
getBuzyPeList
List<Pe> getBuzyPeList()
Gets the list of working Processing Elements (PEs) of the host, which excludes failed PEs.- Returns:
- the list working (non-failed) Host PEs
-
getFreePeList
List<Pe> getFreePeList()
Gets the list of Free Processing Elements (PEs) of the host, which excludes failed PEs.- Returns:
- the list free (non-failed) Host PEs
-
getNumberOfFreePes
int getNumberOfFreePes()
Gets the free pes number.- Returns:
- the free pes number
-
getNumberOfWorkingPes
long getNumberOfWorkingPes()
Gets the number of PEs that are working. That is, the number of PEs that aren't FAIL.- Returns:
- the number of working pes
-
getNumberOfFailedPes
long getNumberOfFailedPes()
Gets the number of PEs that have failed.- Returns:
- the number of failed pes
-
getAvailableMips
double getAvailableMips()
Gets the current amount of available MIPS at the host.- Returns:
- the available amount of MIPS
-
getMaxAvailableMips
double getMaxAvailableMips()
Returns the maximum available MIPS among all the PEs of the host.- Returns:
- max mips
-
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
Host setBwProvisioner(ResourceProvisioner bwProvisioner)
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
Host setRamProvisioner(ResourceProvisioner ramProvisioner)
Sets the ram provisioner with capacity in Megabytes.- Parameters:
ramProvisioner
- the new ram provisioner
-
getVm
Vm getVm(int vmId, int brokerId)
Gets a VM by its id and user.- Parameters:
vmId
- the vm idbrokerId
- ID of VM's owner- Returns:
- the virtual machine object, $null if not found
-
getVmList
<T extends Vm> List<T> getVmList()
Gets a read-only list of VMs currently assigned to the host.- Type Parameters:
T
- The generic type- Returns:
- the read-only vm list
-
getVmCreatedList
<T extends Vm> List<T> 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 list
-
getVmScheduler
VmScheduler getVmScheduler()
Gets the policy for allocation of host PEs to VMs in order to schedule VM execution.- Returns:
- the
VmScheduler
-
setVmScheduler
Host setVmScheduler(VmScheduler vmScheduler)
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:
-
getStartTime
double getStartTime()
Gets the time the Host was powered-on (in seconds).- Returns:
-
setStartTime
void setStartTime(double startTime)
Sets the time the Host was powered-on.- Parameters:
startTime
- the time to set (in seconds)
-
getShutdownTime
double getShutdownTime()
Gets the time the Host shut down.- Returns:
-
setShutdownTime
void setShutdownTime(double shutdownTime)
Sets the time the Host shut down.- Parameters:
shutdownTime
- the time to set
-
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
boolean createVm(Vm vm)
Try to allocate resources to a new VM in the Host.- Parameters:
vm
- Vm being started- Returns:
- $true if the VM could be started in the host; $false otherwise
-
destroyVm
void destroyVm(Vm vm)
Destroys a VM running in the host and removes it from thegetVmList()
.- Parameters:
vm
- the VM
-
createTemporaryVm
boolean 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. For instance, if is being chosen Hosts 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, it 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:
- $true if the VM could be started in the host; $false otherwise
- To do something:
- https://github.com/manoelcampos/cloudsim-plus/issues/94
-
destroyTemporaryVm
void destroyTemporaryVm(Vm vm)
Destroys a temporary VM created into the Host to book resources.- Parameters:
vm
- the VM- See Also:
createTemporaryVm(Vm)
- To do something:
- https://github.com/manoelcampos/cloudsim-plus/issues/94
-
destroyAllVms
void destroyAllVms()
Destroys all VMs running in the host and remove them from thegetVmList()
.
-
addOnUpdateProcessingListener
Host addOnUpdateProcessingListener(EventListener<HostUpdatesVmsProcessingEventInfo> listener)
Adds a listener object that will be notified every time when the host updates the processing of all itsVMs
.- Parameters:
listener
- the OnUpdateProcessingListener to add- Returns:
- See Also:
updateProcessing(double)
-
removeOnUpdateProcessingListener
boolean removeOnUpdateProcessingListener(EventListener<HostUpdatesVmsProcessingEventInfo> listener)
Removes a listener object from the OnUpdateProcessingListener List.- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was found and removed, false otherwise
- See Also:
updateProcessing(double)
-
setSimulation
Host setSimulation(Simulation simulation)
Sets the CloudSim instance that represents the simulation the Entity is related to. Such attribute has to be set by theDatacenter
that the host belongs to.- Parameters:
simulation
- The CloudSim instance that represents the simulation the Entity is related to- Returns:
-
getProvisioner
ResourceProvisioner getProvisioner(Class<? extends ResourceManageable> resourceClass)
- Parameters:
resourceClass
- the class of the resource to get its provisioner- Returns:
- the
ResourceProvisioner
for the given resource class
-
getUtilizationOfCpu
double getUtilizationOfCpu()
Gets current utilization of CPU in percentage (between [0 and 1]), considering the usage of all its PEs..- Returns:
-
getUtilizationOfCpuMips
double getUtilizationOfCpuMips()
Gets the current total utilization of CPU in MIPS, considering the usage of all its PEs.- Returns:
-
getUtilizationOfBw
long getUtilizationOfBw()
Gets the current utilization of bw (in absolute values).- Returns:
-
getUtilizationOfRam
long getUtilizationOfRam()
Gets the current utilization of memory (in absolute values).- Returns:
-
getUtilizationHistory
SortedMap<Double,DoubleSummaryStatistics> getUtilizationHistory()
Gets a map containing the host CPU utilization percentage history (between [0 and 1]), based on its VM utilization history. Each key is a time when the data collection was performed and each value is a
DoubleSummaryStatistics
from where some operations over the CPU utilization entries for every VM inside the Host can be performed, such as counting, summing, averaging, etc. For instance, if you call theDoubleSummaryStatistics.getSum()
, you'll get the total Host's CPU utilization for the time specified by the map key.There is an entry for each time multiple of the
Datacenter.getSchedulingInterval()
. This way, it's required to set a Datacenter scheduling interval with the desired value.In order to enable the Host to get utilization history, its VMs' utilization history must be enabled by calling
enable()
from theVm.getUtilizationHistory()
.- Returns:
- a Map where keys are the data collection time
and each value is a
DoubleSummaryStatistics
objects that provides lots of useful methods to get max, min, average, count and sum of utilization values. - See Also:
getUtilizationHistorySum()
-
getUtilizationHistorySum
SortedMap<Double,Double> getUtilizationHistorySum()
Gets a map containing the host CPU utilization percentage history (between [0 and 1]), based on its VM utilization history. Each key is a time when the data collection was performed and each value is the sum of all CPU utilization of the VMs running inside this Host for that time. This way, the value represents the total Host's CPU utilization for each time that data was collected.
There is an entry for each time multiple of the
Datacenter.getSchedulingInterval()
. This way, it's required to set a Datacenter scheduling interval with the desired value.In order to enable the Host to get utilization history, its VMs' utilization history must be enabled by calling
enable()
from theVm.getUtilizationHistory()
.- Returns:
- a Map where keys are the data collection time
and each value is a
DoubleSummaryStatistics
objects that provides lots of useful methods to get max, min, average, count and sum of utilization values. - See Also:
getUtilizationHistory()
-
getPowerModel
PowerModel getPowerModel()
Gets thePowerModel
used by the host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.- Returns:
- the Host's
PowerModel
-
setPowerModel
Host setPowerModel(PowerModel powerModel)
Sets thePowerModel
used by the host to define how it consumes power. A Host just provides power usage data if a PowerModel is set.- Parameters:
powerModel
- thePowerModel
to set- Returns:
-
getPreviousUtilizationOfCpu
double getPreviousUtilizationOfCpu()
-
enableStateHistory
void enableStateHistory()
Enables storing Host state history.- See Also:
getStateHistory()
-
disableStateHistory
void disableStateHistory()
Disable storing Host state history.- See Also:
getStateHistory()
-
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:
enableStateHistory()
-
getFinishedVms
List<Vm> getFinishedVms()
Gets the List of VMs that have finished executing.- Returns:
-
-