Class DatacenterSimple
java.lang.Object
org.cloudsimplus.core.CloudSimEntity
org.cloudsimplus.datacenters.DatacenterSimple
- All Implemented Interfaces:
Comparable<SimEntity>,Runnable,Identifiable,Nameable,SimEntity,Sizeable,Datacenter,TimeZoned,PowerAware<PowerModelDatacenter>
- Direct Known Subclasses:
NetworkDatacenter
Implements the basic features of a Virtualized Cloud Datacenter,
processing VM queries (i.e., handling of VMs).
- Since:
- CloudSim Toolkit 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cloudsimplus.core.SimEntity
SimEntity.State -
Field Summary
Fields inherited from interface org.cloudsimplus.datacenters.Datacenter
DEF_BW_PERCENT_FOR_MIGRATION, LOGGER, NULLFields inherited from interface org.cloudsimplus.datacenters.TimeZoned
MAX_TIME_ZONE_OFFSET, MIN_TIME_ZONE_OFFSET -
Constructor Summary
ConstructorsConstructorDescriptionDatacenterSimple(Simulation simulation, List<? extends Host> hostList) Creates a Datacenter with an emptystorageand aVmAllocationPolicySimpleby 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 emptystorageand no Hosts. -
Method Summary
Modifier and TypeMethodDescription<T extends Host>
DatacenteraddHost(T host) Physically expands the Datacenter by adding a newHost(physical machine) to it.<T extends Host>
DatacenteraddHostList(List<T> hostList) Physically expands the Datacenter by adding a List of newHosts (physical machines) to it.addOnHostAvailableListener(EventListener<HostEventInfo> listener) Adds aEventListenerobject that will be notified every time a new Host is available for the Datacenter during simulation runtime.Adds aEventListenerobject that will be notified every time a VM migration is finished either successfully or not.final DatacenterDisable VM migrations.final DatacenterEnable VM migrations.protected booleanfinishVmMigration(SimEvent evt, boolean ack) Finishes the process of migrating a VM.protected doublegetCloudletProcessingUpdateInterval(double nextFinishingCloudletTime) Returns the next time Cloudlets processing will be updated (a relative delay from the current simulation time).getHost(int index) Returns a Host in a given position inside the Host List.getHostById(long id) Gets a Host from its id.Returns an unmodifiable host list.booleanprotected booleanprocessCloudlet(SimEvent evt, int tag) Processes a Cloudlet based on the event type.protected booleanprocessCloudletCancel(Cloudlet cloudlet) Processes a Cloudlet cancel request.protected booleanprocessCloudletPause(Cloudlet cloudlet, boolean ack) Processes a Cloudlet pause request.protected booleanprocessCloudletResume(Cloudlet cloudlet, boolean ack) Processes a Cloudlet resume request.protected booleanprocessCloudletSubmit(SimEvent evt, boolean ack) Processes the submission of a Cloudlet by a DatacenterBroker.voidprocessEvent(SimEvent evt) Processes events or services that are available for the entity.protected voidProcesses a ping request.protected booleanprocessVmDestroy(SimEvent evt) 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.voidrequestVmMigration(Vm sourceVm) voidrequestVmMigration(Vm sourceVm, Host targetHost) voidsetBandwidthPercentForMigration(double bandwidthPercentForMigration) Sets the percentage of the bandwidth allocated to a Host to migrate VMs.setCharacteristics(@NonNull DatacenterCharacteristics c) Sets the Datacenter characteristics.final voidsetDatacenterStorage(DatacenterStorage datacenterStorage) Sets the storage device 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.final DatacentersetPowerModel(PowerModelDatacenter powerModel) Sets the model defining how the entity consumes power.final DatacentersetSchedulingInterval(double schedulingInterval) Sets the scheduling delay to process each event received by the Datacenter.final DatacentersetTimeZone(double timeZone) Sets the time zone offset between [TimeZoned.MIN_TIME_ZONE_OFFSETandTimeZoned.MAX_TIME_ZONE_OFFSET].protected longfinal DatacentersetVmAllocationPolicy(VmAllocationPolicy vmAllocationPolicy) voidshutdown()Shuts down the entity.longsize()protected voidDefines the logic to be performed by the entity when the simulation starts.toString()voidupdateActiveHostsNumber(Host host) Update the number of active Hosts inside the datacenterprotected doubleUpdates the processing of each Host, that fires the update of VMs, which in turn updates cloudlets running in this Datacenter.protected doubleUpdates the processing of all Hosts, meaning it makes the processing of VMs running inside such hosts to be updated.Methods inherited from class org.cloudsimplus.core.CloudSimEntity
cancelEvent, compareTo, getNextEvent, getNextEvent, 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, start, waitForEventMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.cloudsimplus.datacenters.Datacenter
getActiveHostsNumber, getBandwidthPercentForMigration, getCharacteristics, getDatacenterStorage, getHostSearchRetryDelay, getSchedulingInterval, getVmAllocationPolicyMethods inherited from interface org.cloudsimplus.core.Identifiable
getIdMethods inherited from interface org.cloudsimplus.power.PowerAware
getPowerModelMethods inherited from interface org.cloudsimplus.core.SimEntity
getShutdownTime, getSimulation, getStartTime, getState, isAlive, isFinished, isStarted, run, schedule, schedule, schedule, schedule, schedule, schedule, schedule, setName, setState, startMethods inherited from interface org.cloudsimplus.datacenters.TimeZoned
distance, getTimeZone, validateTimeZone
-
Constructor Details
-
DatacenterSimple
Creates a Datacenter with an emptystorageand aVmAllocationPolicySimpleby default.NOTE: To change such attributes, just call the respective setters.
- Parameters:
simulation- theCloudSimPlusinstance that represents the simulation the Entity belongshostList- list ofHosts 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- theCloudSimPlusinstance that represents the simulation the Entity belongshostList- list ofHosts that will compound the DatacentervmAllocationPolicy- the policy to be used to allocateVms intoHosts- See Also:
-
DatacenterSimple
Creates a Datacenter with an emptystorageand no Hosts.- Parameters:
simulation- theCloudSimPlusinstance that represents the simulation the Entity belongsvmAllocationPolicy- the policy to be used to allocateVms intoHosts- 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- theCloudSimPlusinstance that represents the simulation the Entity belongshostList- list ofHosts that will compound the DatacentervmAllocationPolicy- the policy to be used to allocateVms intoHostsstorageList- theSanStoragelist to attach to thedatacenter storage
-
DatacenterSimple
public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, DatacenterStorage storage) Creates a Datacenter with a givenstorage.- Parameters:
simulation- theCloudSimPlusinstance that represents the simulation the Entity belongshostList- list ofHosts that will compound the DatacentervmAllocationPolicy- the policy to be used to allocate VMs into hostsstorage- thestoragefor this Datacenter- See Also:
-
-
Method Details
-
setupHost
-
processEvent
Description copied from interface:SimEntityProcesses events or services that are available for the entity. This method is invoked, by theCloudSimPlusclass, whenever there is an event in the deferred queue that needs to be processed by the entity.- Specified by:
processEventin 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:
- true if the event was processed, false otherwise
-
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:
- true if the event was processed, false otherwise
-
getCloudletProcessingUpdateInterval
protected double getCloudletProcessingUpdateInterval(double nextFinishingCloudletTime) Returns the next time Cloudlets processing will be updated (a relative delay from the current simulation time). This is the minimum value between theDatacenter.getSchedulingInterval()and the given time (if the scheduling interval is enabled, i.e., if it's greater than 0), which indicates 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_VALUEif there is no next Cloudlet to execute- Returns:
- the 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 a confirmation (ack) message- Returns:
- true to indicate the event was processed
-
processCloudletPause
Processes a Cloudlet pause request.- Parameters:
cloudlet- cloudlet to be pausedack- indicates if the event's sender expects to receive a confirmation (ack) message- Returns:
- true to indicate the event was processed
-
processCloudletCancel
Processes a Cloudlet cancel request.- Parameters:
cloudlet- cloudlet to be canceled- Returns:
- true to indicate the event was processed
-
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 happened- Returns:
- true or false to indicate the event was processed or not
-
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 a confirmation (ack) message- Returns:
- true or false to indicate the event was processed or not
- 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_VALUEif there is no next Cloudlet to execute
-
updateCloudletProcessing
protected double updateCloudletProcessing()Updates the 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. That is necessary because Hosts and VMs are simple objects, not entities. So, they don't receive events, therefore, 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_VALUEif: (i) there is no next Cloudlet to execute, or (ii) it isn't time to update the cloudlets.
-
requestVmMigration
Description copied from interface:DatacenterSends an event to request the migration of aVmto some suitableHoston this Datacenter. A suitable Host will try to be found when the Datacenter processes the migration request message. If you want VM migrations to be performed automatically, use aVmAllocationPolicyMigration.- Specified by:
requestVmMigrationin interfaceDatacenter- Parameters:
sourceVm- the VM to be migrated- See Also:
-
requestVmMigration
Description copied from interface:DatacenterSends an event to request the migration of aVmto a given targetHoston this Datacenter. If you want VM migrations to be performed automatically, use aVmAllocationPolicyMigration.- Specified by:
requestVmMigrationin 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:SimEntityShuts down the entity. This method is invoked byCloudSimPlusbefore the simulation finishes. If you want to save data in log files, this is the method in which the corresponding code may be placed.- Specified by:
shutdownin interfaceSimEntity- Overrides:
shutdownin classCloudSimEntity
-
startInternal
protected void startInternal()Description copied from class:CloudSimEntityDefines the logic to be performed by the entity when the simulation starts.- Specified by:
startInternalin classCloudSimEntity
-
getHostList
Description copied from interface:DatacenterReturns an unmodifiable host list.- Specified by:
getHostListin interfaceDatacenter- Type Parameters:
T- The generic type- Returns:
- an unmodifiable host list
-
getActiveHostStream
- Specified by:
getActiveHostStreamin interfaceDatacenter- Returns:
- a
Streamcontaining the active Hosts inside the Datacenter.
-
setVmAllocationPolicy
- Parameters:
vmAllocationPolicy- the new vm allocation policy- Returns:
- this Datacenter
-
setDatacenterStorage
Description copied from interface:DatacenterSets the storage device of the Datacenter.- Specified by:
setDatacenterStoragein interfaceDatacenter- Parameters:
datacenterStorage- the new storage
-
setSchedulingInterval
Description copied from interface:DatacenterSets the scheduling delay to process each event received by the Datacenter.- Specified by:
setSchedulingIntervalin interfaceDatacenter- Parameters:
schedulingInterval- the new scheduling interval (in seconds)- Returns:
- this Datacenter
- See Also:
-
setTimeZone
Description copied from interface:TimeZonedSets the time zone offset between [TimeZoned.MIN_TIME_ZONE_OFFSETandTimeZoned.MAX_TIME_ZONE_OFFSET].- Specified by:
setTimeZonein interfaceTimeZoned- Parameters:
timeZone- the new time zone offset- Returns:
- this instance
-
getHost
Description copied from interface:DatacenterReturns a Host in a given position inside the Host List.- Specified by:
getHostin interfaceDatacenter- Parameters:
index- the position of the List to get the Host- Returns:
- a Host in a given position inside the Host List
-
updateActiveHostsNumber
Update the number of active Hosts inside the datacenter -
size
public long size()- Specified by:
sizein interfaceDatacenter- Specified by:
sizein interfaceSizeable- Returns:
- the total number of existing Hosts in this Datacenter, which indicates the Datacenter's size.
-
getHostById
Description copied from interface:DatacenterGets a Host from its id.- Specified by:
getHostByIdin interfaceDatacenter- Parameters:
id- the ID of the Host to get from the List.- Returns:
- the Host if found or
Host.NULLotherwise
-
addHostList
Description copied from interface:DatacenterPhysically expands the Datacenter by adding a List of newHosts (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:
addHostListin interfaceDatacenter- Parameters:
hostList- the List of new hosts to be added- Returns:
- this Datacenter
- See Also:
-
addHost
Description copied from interface:DatacenterPhysically expands the Datacenter by adding a newHost(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:
addHostin interfaceDatacenter- Parameters:
host- the new host to be added- Returns:
- this Datacenter
- See Also:
-
removeHost
Description copied from interface:DatacenterRemoves a Host from its Datacenter.- Specified by:
removeHostin interfaceDatacenter- Parameters:
host- the new host to be removed from its assigned Datacenter- Returns:
- this Datacenter
-
toString
-
setBandwidthPercentForMigration
public void setBandwidthPercentForMigration(double bandwidthPercentForMigration) Description copied from interface:DatacenterSets 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:
setBandwidthPercentForMigrationin interfaceDatacenter- Parameters:
bandwidthPercentForMigration- the bandwidth migration percentage to set
-
addOnHostAvailableListener
Description copied from interface:DatacenterAdds aEventListenerobject 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:
addOnHostAvailableListenerin interfaceDatacenter- Parameters:
listener- the event listener to add- Returns:
- this Datacenter
-
addOnVmMigrationFinishListener
public Datacenter addOnVmMigrationFinishListener(EventListener<DatacenterVmMigrationEventInfo> listener) Description copied from interface:DatacenterAdds aEventListenerobject that will be notified every time a VM migration is finished either successfully or not.- Specified by:
addOnVmMigrationFinishListenerin interfaceDatacenter- Parameters:
listener- the event listener to add- Returns:
- this Datacenter
-
isMigrationsEnabled
public boolean isMigrationsEnabled()- Specified by:
isMigrationsEnabledin interfaceDatacenter- Returns:
- true, if migrations are enabled; false otherwise
-
enableMigrations
Description copied from interface:DatacenterEnable VM migrations.- Specified by:
enableMigrationsin interfaceDatacenter- Returns:
- this Datacenter
- See Also:
-
disableMigrations
Description copied from interface:DatacenterDisable VM migrations.- Specified by:
disableMigrationsin interfaceDatacenter- Returns:
- this Datacenter
- See Also:
-
setPowerModel
Description copied from interface:PowerAwareSets the model defining how the entity consumes power.- Specified by:
setPowerModelin interfacePowerAware<PowerModelDatacenter>- Parameters:
powerModel- the model to set
-
setHostSearchRetryDelay
Description copied from interface:DatacenterSets the time interval before trying to find suitable Hosts to migrate VMs from an under or overload Host again.- Specified by:
setHostSearchRetryDelayin 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:
- this Datacenter
-
setCharacteristics
Description copied from interface:DatacenterSets the Datacenter characteristics.- Specified by:
setCharacteristicsin interfaceDatacenter- Parameters:
c- the characteristics to set
-