Class DatacenterSimple
- All Implemented Interfaces:
Cloneable
,Comparable<SimEntity>
,Runnable
,Identifiable
,Nameable
,SimEntity
,Sizeable
,Datacenter
,TimeZoned
,PowerAware<PowerModelDatacenter>
- Direct Known Subclasses:
NetworkDatacenter
- Since:
- CloudSim Toolkit 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cloudbus.cloudsim.core.SimEntity
SimEntity.State
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.datacenters.Datacenter
DEF_BW_PERCENT_FOR_MIGRATION, LOGGER, NULL
Fields inherited from interface org.cloudbus.cloudsim.datacenters.TimeZoned
MAX_TIME_ZONE_OFFSET, MIN_TIME_ZONE_OFFSET
-
Constructor Summary
ConstructorDescriptionDatacenterSimple
(Simulation simulation, List<? extends Host> hostList) Creates a Datacenter with an emptystorage
and aVmAllocationPolicySimple
by default.DatacenterSimple
(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy) Creates a Datacenter with an emptystorage
.DatacenterSimple
(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, List<SanStorage> storageList) Creates a Datacenter attaching a given storage list to itsstorage
.DatacenterSimple
(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, DatacenterStorage storage) Creates a Datacenter with a givenstorage
.DatacenterSimple
(Simulation simulation, VmAllocationPolicy vmAllocationPolicy) Creates a Datacenter with an emptystorage
and no Hosts. -
Method Summary
Modifier and TypeMethodDescription<T extends Host>
DatacenteraddHost
(T host) Physically expands the Datacenter by adding a new Host (physical machine) to it.<T extends Host>
DatacenteraddHostList
(List<T> hostList) Physically expands the Datacenter by adding a List of new Hosts (physical machines) to it.addOnHostAvailableListener
(EventListener<HostEventInfo> listener) Adds aEventListener
object that will be notified every time a new Host is available for the Datacenter during simulation runtime.Adds aEventListener
object that will be notified every time a VM migration is finished either successfully or not.final Datacenter
Disable VM migrations.final Datacenter
Enable VM migrations.boolean
protected boolean
finishVmMigration
(SimEvent evt, boolean ack) Finishes the process of migrating a VM.long
Gets the current number of Hosts that are powered on inside the Datacenter.Gets aStream
containing the active Hosts inside the Datacenter.double
Gets the percentage of the bandwidth allocated to a Host to migrate VMs.Gets the Datacenter characteristics.protected double
getCloudletProcessingUpdateInterval
(double nextFinishingCloudletTime) Gets the time when the next update of cloudlets has to be performed.Gets the storage of the Datacenter.getHost
(int index) Gets a Host in a given position inside the Host List.getHostById
(long id) Gets a Host from its id.Gets an unmodifiable host list.double
Gets the time interval before trying to find suitable Hosts to migrate VMs from an under or overload Host again.protected double
Gets the last time some cloudlet was processed in the Datacenter.Gets the model defining how the entity consumes power.double
Gets the scheduling interval to process each event received by the Datacenter (in seconds).double
Gets the time zone offset, a value between [TimeZoned.MIN_TIME_ZONE_OFFSET
andTimeZoned.MAX_TIME_ZONE_OFFSET
], in which the object is physically located.Gets the policy to be used by the Datacenter to allocate VMs into hosts.int
hashCode()
boolean
Checks if migrations are enabled.protected boolean
processCloudlet
(SimEvent evt, CloudSimTag tag) Processes a Cloudlet based on the event type.protected boolean
processCloudletCancel
(Cloudlet cloudlet) Processes a Cloudlet cancel request.protected boolean
processCloudletPause
(Cloudlet cloudlet, boolean ack) Processes a Cloudlet pause request.protected boolean
processCloudletResume
(Cloudlet cloudlet, boolean ack) Processes a Cloudlet resume request.protected boolean
processCloudletSubmit
(SimEvent evt, boolean ack) Processes the submission of a Cloudlet by a DatacenterBroker.void
processEvent
(SimEvent evt) Processes events or services that are available for the entity.protected void
Processes a ping request.protected boolean
processVmDestroy
(SimEvent evt, boolean ack) Process the event sent by a Broker, requesting the destruction of a given VM created in this Datacenter.<T extends Host>
DatacenterremoveHost
(T host) Removes a Host from its Datacenter.void
requestVmMigration
(Vm sourceVm) void
requestVmMigration
(Vm sourceVm, Host targetHost) void
setBandwidthPercentForMigration
(double bandwidthPercentForMigration) Sets the percentage of the bandwidth allocated to a Host to migrate VMs.final void
setDatacenterStorage
(DatacenterStorage datacenterStorage) Sets the storage of the Datacenter.setHostSearchRetryDelay
(double delay) Sets the time interval before trying to find suitable Hosts to migrate VMs from an under or overload Host again.protected final void
setLastProcessTime
(double lastProcessTime) Sets the last time some cloudlet was processed in the Datacenter.final void
setPowerModel
(PowerModelDatacenter powerModel) Sets the model defining how the entity consumes power.final Datacenter
setSchedulingInterval
(double schedulingInterval) Sets the scheduling delay to process each event received by the Datacenter (in seconds).final Datacenter
setTimeZone
(double timeZone) Sets the time zone offset between [TimeZoned.MIN_TIME_ZONE_OFFSET
andTimeZoned.MAX_TIME_ZONE_OFFSET
].protected long
final Datacenter
setVmAllocationPolicy
(VmAllocationPolicy vmAllocationPolicy) Sets the policy to be used by the Datacenter to allocate VMs into hosts.void
shutdown()
Shuts down the entity.long
size()
Gets the total number of existing Hosts in this Datacenter, which indicates the Datacenter's size.protected void
Defines the logic to be performed by the entity when the simulation starts.toString()
void
updateActiveHostsNumber
(Host host) Update the number of active Hosts inside the datacenterprotected double
Updates processing of each Host, that fires the update of VMs, which in turn updates cloudlets running in this Datacenter.protected double
Updates the processing of all Hosts, meaning it makes the processing of VMs running inside such hosts to be updated.Methods inherited from class org.cloudbus.cloudsim.core.CloudSimEntity
cancelEvent, clone, compareTo, getId, getName, getNextEvent, getNextEvent, getShutdownTime, getSimulation, getStartTime, getState, isAlive, isFinished, isStarted, pause, run, run, schedule, schedule, schedule, schedule, schedule, schedule, scheduleFirst, scheduleFirst, scheduleFirstNow, scheduleFirstNow, scheduleNow, scheduleNow, selectEvent, send, send, sendNow, sendNow, setEventBuffer, setId, setName, setSimulation, setState, start, waitForEvent
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
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.SimEntity
getShutdownTime, getSimulation, getStartTime, getState, isAlive, isFinished, isStarted, run, schedule, schedule, schedule, schedule, schedule, schedule, schedule, setName, setSimulation, setState, start
Methods inherited from interface org.cloudbus.cloudsim.datacenters.TimeZoned
distance, validateTimeZone
-
Constructor Details
-
DatacenterSimple
Creates a Datacenter with an emptystorage
and aVmAllocationPolicySimple
by default.NOTE: To change such attributes, just call the respective setters.
- Parameters:
simulation
- the CloudSim instance that represents the simulation the Entity belongshostList
- list ofHost
s that will compound the Datacenter- See Also:
-
DatacenterSimple
public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy) Creates a Datacenter with an emptystorage
.- Parameters:
simulation
- the CloudSim instance that represents the simulation the Entity belongshostList
- list ofHost
s that will compound the DatacentervmAllocationPolicy
- the policy to be used to allocate VMs into hosts- See Also:
-
DatacenterSimple
Creates a Datacenter with an emptystorage
and no Hosts.- Parameters:
simulation
- the CloudSim instance that represents the simulation the Entity belongsvmAllocationPolicy
- the policy to be used to allocate VMs into hosts- See Also:
-
DatacenterSimple
public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, List<SanStorage> storageList) Creates a Datacenter attaching a given storage list to itsstorage
.- Parameters:
simulation
- the CloudSim instance that represents the simulation the Entity belongshostList
- list ofHost
s that will compound the DatacentervmAllocationPolicy
- the policy to be used to allocate VMs into hostsstorageList
- the storage list to attach to thedatacenter storage
-
DatacenterSimple
public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, DatacenterStorage storage) Creates a Datacenter with a givenstorage
.
-
-
Method Details
-
setupHost
-
processEvent
Description copied from interface:SimEntity
Processes events or services that are available for the entity. This method is invoked by theCloudSim
class whenever there is an event in the deferred queue, which needs to be processed by the entity.- Specified by:
processEvent
in interfaceSimEntity
- Parameters:
evt
- information about the event just happened
-
processPingRequest
Processes a ping request.- Parameters:
evt
- information about the event just happened
-
processCloudlet
Processes a Cloudlet based on the event type.- Parameters:
evt
- information about the event just happenedtag
- event tag- Returns:
-
processCloudletSubmit
Processes the submission of a Cloudlet by a DatacenterBroker.- Parameters:
evt
- information about the event just happenedack
- indicates if the event's sender expects to receive an acknowledgement- Returns:
-
getCloudletProcessingUpdateInterval
protected double getCloudletProcessingUpdateInterval(double nextFinishingCloudletTime) Gets the time when the next update of cloudlets has to be performed. This is the minimum value between thegetSchedulingInterval()
and the given time (if the scheduling interval is enable, i.e. if it's greater than 0), which represents when the next update of Cloudlets processing has to be performed.- Parameters:
nextFinishingCloudletTime
- the predicted completion time of the earliest finishing cloudlet (which is a relative delay from the current simulation time), orDouble.MAX_VALUE
if there is no next Cloudlet to execute- Returns:
- next time cloudlets processing will be updated (a relative delay from the current simulation time)
- See Also:
-
processCloudletResume
Processes a Cloudlet resume request.- Parameters:
cloudlet
- cloudlet to be resumedack
- indicates if the event's sender expects to receive an- Returns:
-
processCloudletPause
Processes a Cloudlet pause request.- Parameters:
cloudlet
- cloudlet to be pausedack
- indicates if the event's sender expects to receive an- Returns:
-
processCloudletCancel
Processes a Cloudlet cancel request.- Parameters:
cloudlet
- cloudlet to be canceled- Returns:
-
processVmDestroy
Process the event sent by a Broker, requesting the destruction of a given VM created in this Datacenter. This Datacenter may send, upon request, the status back to the Broker.- Parameters:
evt
- information about the event just happenedack
- indicates if the event's sender expects to receive an- Returns:
-
finishVmMigration
Finishes the process of migrating a VM.- Parameters:
evt
- information about the event just happenedack
- indicates if the event's sender expects to receive an acknowledgement message when the event finishes being processed- Returns:
- See Also:
-
updateHostsProcessing
protected double updateHostsProcessing()Updates the processing of all Hosts, meaning it makes the processing of VMs running inside such hosts to be updated. Finally, the processing of Cloudlets running inside such VMs is updated too.- 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
-
updateCloudletProcessing
protected double updateCloudletProcessing()Updates processing of each Host, that fires the update of VMs, which in turn updates cloudlets running in this Datacenter. After that, the method schedules the next processing update. It is necessary because Hosts and VMs are simple objects, not entities. So, they don't receive events and updating cloudlets inside them must be called from the outside.- 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 or it isn't time to update the cloudlets
-
requestVmMigration
Description copied from interface:Datacenter
Sends an event to request the migration of aVm
to some suitableHost
on this Datacenter. A suitable Host will try to be found when the migration request message is processed by the Datacenter. If you want VM migrations to be performed automatically, use aVmAllocationPolicyMigration
.- Specified by:
requestVmMigration
in interfaceDatacenter
- Parameters:
sourceVm
- the VM to be migrated- See Also:
-
requestVmMigration
Description copied from interface:Datacenter
Sends an event to request the migration of aVm
to a given targetHost
on this Datacenter. If you want VM migrations to be performed automatically, use aVmAllocationPolicyMigration
.- Specified by:
requestVmMigration
in interfaceDatacenter
- Parameters:
sourceVm
- the VM to be migratedtargetHost
- the target Host to migrate the VM to- See Also:
-
shutdown
public void shutdown()Description copied from interface:SimEntity
Shuts down the entity. This method is invoked by theCloudSim
before the simulation finishes. If you want to save data in log files this is the method in which the corresponding code would be placed.- Specified by:
shutdown
in interfaceSimEntity
- Overrides:
shutdown
in classCloudSimEntity
-
startInternal
protected void startInternal()Description copied from class:CloudSimEntity
Defines the logic to be performed by the entity when the simulation starts.- Specified by:
startInternal
in classCloudSimEntity
-
getHostList
Description copied from interface:Datacenter
Gets an unmodifiable host list.- Specified by:
getHostList
in interfaceDatacenter
- Type Parameters:
T
- The generic type- Returns:
- the host list
-
getActiveHostStream
Description copied from interface:Datacenter
Gets aStream
containing the active Hosts inside the Datacenter.- Specified by:
getActiveHostStream
in interfaceDatacenter
- Returns:
- the active host Stream
-
getCharacteristics
Description copied from interface:Datacenter
Gets the Datacenter characteristics.- Specified by:
getCharacteristics
in interfaceDatacenter
- Returns:
- the characteristics
-
getVmAllocationPolicy
Description copied from interface:Datacenter
Gets the policy to be used by the Datacenter to allocate VMs into hosts.- Specified by:
getVmAllocationPolicy
in interfaceDatacenter
- Returns:
- the VM allocation policy
- See Also:
-
setVmAllocationPolicy
Sets the policy to be used by the Datacenter to allocate VMs into hosts.- Parameters:
vmAllocationPolicy
- the new vm allocation policy
-
getLastProcessTime
protected double getLastProcessTime()Gets the last time some cloudlet was processed in the Datacenter.- Returns:
- the last process time
-
setLastProcessTime
protected final void setLastProcessTime(double lastProcessTime) Sets the last time some cloudlet was processed in the Datacenter.- Parameters:
lastProcessTime
- the new last process time
-
getDatacenterStorage
Description copied from interface:Datacenter
Gets the storage of the Datacenter.- Specified by:
getDatacenterStorage
in interfaceDatacenter
- Returns:
- the storage
-
setDatacenterStorage
Description copied from interface:Datacenter
Sets the storage of the Datacenter.- Specified by:
setDatacenterStorage
in interfaceDatacenter
- Parameters:
datacenterStorage
- the new storage
-
getSchedulingInterval
public double getSchedulingInterval()Description copied from interface:Datacenter
Gets the scheduling interval to process each event received by the Datacenter (in seconds). This value defines the interval in which processing of Cloudlets will be updated. The interval doesn't affect the processing of such cloudlets, it only defines in which interval the processing will be updated. For instance, if it is set an interval of 10 seconds, the processing of cloudlets will be updated at every 10 seconds.Trying to get the amount of instructions the cloudlet has executed after 5 seconds, by means of
Cloudlet.getFinishedLengthSoFar(Datacenter)
, won't return an updated value. This way, one should set the scheduling interval to 5 to get updated data. As longer is the interval, faster will be the simulation execution.The default value is zero, which indicates no scheduling interval is set and the simulation state is updated only when a cloudlet is finished. That ensures the highest performance but may not be desired if you want to collect some simulation data in a defined time interval.
- Specified by:
getSchedulingInterval
in interfaceDatacenter
- Returns:
- the scheduling interval (in seconds)
-
setSchedulingInterval
Description copied from interface:Datacenter
Sets the scheduling delay to process each event received by the Datacenter (in seconds).- Specified by:
setSchedulingInterval
in interfaceDatacenter
- Parameters:
schedulingInterval
- the new scheduling interval (in seconds)- Returns:
- See Also:
-
getTimeZone
public double getTimeZone()Description copied from interface:TimeZoned
Gets the time zone offset, a value between [TimeZoned.MIN_TIME_ZONE_OFFSET
andTimeZoned.MAX_TIME_ZONE_OFFSET
], in which the object is physically located.- Specified by:
getTimeZone
in interfaceTimeZoned
- Returns:
- the time zone offset
-
setTimeZone
Description copied from interface:TimeZoned
Sets the time zone offset between [TimeZoned.MIN_TIME_ZONE_OFFSET
andTimeZoned.MAX_TIME_ZONE_OFFSET
].- Specified by:
setTimeZone
in interfaceTimeZoned
- Parameters:
timeZone
- the new time zone offset- Returns:
-
getHost
Description copied from interface:Datacenter
Gets a Host in a given position inside the Host List.- Specified by:
getHost
in interfaceDatacenter
- Parameters:
index
- the position of the List to get the Host- Returns:
-
getActiveHostsNumber
public long getActiveHostsNumber()Description copied from interface:Datacenter
Gets the current number of Hosts that are powered on inside the Datacenter.- Specified by:
getActiveHostsNumber
in interfaceDatacenter
- Returns:
- See Also:
-
updateActiveHostsNumber
Update the number of active Hosts inside the datacenter -
size
public long size()Description copied from interface:Datacenter
Gets the total number of existing Hosts in this Datacenter, which indicates the Datacenter's size.- Specified by:
size
in interfaceDatacenter
- Specified by:
size
in interfaceSizeable
- Returns:
-
getHostById
Description copied from interface:Datacenter
Gets a Host from its id.- Specified by:
getHostById
in interfaceDatacenter
- Parameters:
id
- the ID of the Host to get from the List.- Returns:
- the Host if found or
Host.NULL
otherwise
-
addHostList
Description copied from interface:Datacenter
Physically expands the Datacenter by adding a List of new Hosts (physical machines) to it. Hosts can be added before or after the simulation has started. If a Host is added during simulation execution, in case VMs are added dynamically too, they may be allocated to this new Host, depending on theVmAllocationPolicy
.If an ID is not assigned to a Host, the method assigns one.
- Specified by:
addHostList
in interfaceDatacenter
- Parameters:
hostList
- the List of new hosts to be added- Returns:
- See Also:
-
addHost
Description copied from interface:Datacenter
Physically expands the Datacenter by adding a new Host (physical machine) to it. Hosts can be added before or after the simulation has started. If a Host is added during simulation execution, in case VMs are added dynamically too, they may be allocated to this new Host, depending on theVmAllocationPolicy
.If an ID is not assigned to the given Host, the method assigns one.
- Specified by:
addHost
in interfaceDatacenter
- Parameters:
host
- the new host to be added- Returns:
- See Also:
-
removeHost
Description copied from interface:Datacenter
Removes a Host from its Datacenter.- Specified by:
removeHost
in interfaceDatacenter
- Parameters:
host
- the new host to be removed from its assigned Datacenter- Returns:
-
toString
-
equals
- Overrides:
equals
in classCloudSimEntity
-
hashCode
public int hashCode()- Overrides:
hashCode
in classCloudSimEntity
-
getBandwidthPercentForMigration
public double getBandwidthPercentForMigration()Description copied from interface:Datacenter
Gets the percentage of the bandwidth allocated to a Host to migrate VMs. It's a value between [0 and 1] (where 1 is 100%). The default value is 0.5, meaning only 50% of the bandwidth will be allowed for migration, while the remaining will be used for VM services.- Specified by:
getBandwidthPercentForMigration
in interfaceDatacenter
- Returns:
- See Also:
-
setBandwidthPercentForMigration
public void setBandwidthPercentForMigration(double bandwidthPercentForMigration) Description copied from interface:Datacenter
Sets the percentage of the bandwidth allocated to a Host to migrate VMs. It's a value between [0 and 1] (where 1 is 100%). The default value is 0.5, meaning only 50% of the bandwidth will be allowed for migration, while the remaining will be used for VM services.- Specified by:
setBandwidthPercentForMigration
in interfaceDatacenter
- Parameters:
bandwidthPercentForMigration
- the bandwidth migration percentage to set
-
addOnHostAvailableListener
Description copied from interface:Datacenter
Adds aEventListener
object that will be notified every time a new Host is available for the Datacenter during simulation runtime. If theDatacenter.addHost(Host)
orDatacenter.addHostList(List)
is called before the simulation starts, the listeners will not be notified.- Specified by:
addOnHostAvailableListener
in interfaceDatacenter
- Parameters:
listener
- the event listener to add- Returns:
-
addOnVmMigrationFinishListener
public Datacenter addOnVmMigrationFinishListener(EventListener<DatacenterVmMigrationEventInfo> listener) Description copied from interface:Datacenter
Adds aEventListener
object that will be notified every time a VM migration is finished either successfully or not.- Specified by:
addOnVmMigrationFinishListener
in interfaceDatacenter
- Parameters:
listener
- the event listener to add- Returns:
-
isMigrationsEnabled
public boolean isMigrationsEnabled()Description copied from interface:Datacenter
Checks if migrations are enabled.- Specified by:
isMigrationsEnabled
in interfaceDatacenter
- Returns:
- true, if migrations are enable; false otherwise
-
enableMigrations
Description copied from interface:Datacenter
Enable VM migrations.- Specified by:
enableMigrations
in interfaceDatacenter
- Returns:
- See Also:
-
disableMigrations
Description copied from interface:Datacenter
Disable VM migrations.- Specified by:
disableMigrations
in interfaceDatacenter
- Returns:
-
getPowerModel
Description copied from interface:PowerAware
Gets the model defining how the entity consumes power.- Specified by:
getPowerModel
in interfacePowerAware<PowerModelDatacenter>
- Returns:
-
setPowerModel
Description copied from interface:PowerAware
Sets the model defining how the entity consumes power.- Specified by:
setPowerModel
in interfacePowerAware<PowerModelDatacenter>
- Parameters:
powerModel
- the model to set
-
getHostSearchRetryDelay
public double getHostSearchRetryDelay()Description copied from interface:Datacenter
Gets the time interval before trying to find suitable Hosts to migrate VMs from an under or overload Host again.- Specified by:
getHostSearchRetryDelay
in interfaceDatacenter
- Returns:
- the Host search delay (in seconds)
-
setHostSearchRetryDelay
Description copied from interface:Datacenter
Sets the time interval before trying to find suitable Hosts to migrate VMs from an under or overload Host again.- Specified by:
setHostSearchRetryDelay
in interfaceDatacenter
- Parameters:
delay
- the new delay to set (in seconds). Give a positive value to define an actual delay or a negative value to indicate a new Host search for VM migration must be tried as soon as possible- Returns:
-