DatacenterSimple

public class DatacenterSimple extends CloudSimEntity implements Datacenter

Implements the basic features of a Virtualized Cloud Datacenter. It deals with processing of VM queries (i.e., handling of VMs) instead of processing Cloudlet-related queries.

Author:Rodrigo N. Calheiros, Anton Beloglazov

Constructors

DatacenterSimple

public DatacenterSimple(Simulation simulation, VmAllocationPolicy vmAllocationPolicy)

Creates a Datacenter with an empty storage and no Hosts.

Parameters:
  • simulation – The CloudSim instance that represents the simulation the Entity is related to
  • vmAllocationPolicy – the policy to be used to allocate VMs into hosts

See also: .DatacenterSimple(Simulation,List,VmAllocationPolicy), .DatacenterSimple(Simulation,List,VmAllocationPolicy,DatacenterStorage), .addHostList(List)

DatacenterSimple

public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy)

Creates a Datacenter with an empty storage.

Parameters:
  • simulation – The CloudSim instance that represents the simulation the Entity is related to
  • hostList – list of Hosts that will compound the Datacenter
  • vmAllocationPolicy – the policy to be used to allocate VMs into hosts

See also: .DatacenterSimple(Simulation,List,VmAllocationPolicy,DatacenterStorage)

DatacenterSimple

public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, List<FileStorage> storageList)

Creates a Datacenter attaching a given storage list to its storage.

Parameters:
  • simulation – The CloudSim instance that represents the simulation the Entity is related to
  • hostList – list of Hosts that will compound the Datacenter
  • vmAllocationPolicy – the policy to be used to allocate VMs into hosts
  • storageList – the storage list to attach to the datacenter storage

DatacenterSimple

public DatacenterSimple(Simulation simulation, List<? extends Host> hostList, VmAllocationPolicy vmAllocationPolicy, DatacenterStorage storage)

Creates a Datacenter with a given storage.

Parameters:
  • simulation – The CloudSim instance that represents the simulation the Entity is related to
  • hostList – list of Hosts that will compound the Datacenter
  • vmAllocationPolicy – the policy to be used to allocate VMs into hosts
  • storage – the storage for this Datacenter

See also: DatacenterStorage.getStorageList()

Methods

addHost

public <T extends Host> Datacenter addHost(T host)

addHostList

public <T extends Host> Datacenter addHostList(List<T> hostList)

addOnHostAvailableListener

public Datacenter addOnHostAvailableListener(EventListener<HostEventInfo> listener)

checkCloudletsCompletionForAllHosts

protected void checkCloudletsCompletionForAllHosts()

Verifies if some cloudlet inside the hosts of this Datacenter have already finished. If yes, send them to the User/Broker

disableMigrations

public final Datacenter disableMigrations()

Disable VM migrations.

enableMigrations

public final Datacenter enableMigrations()

Enable VM migrations.

equals

public boolean equals(Object object)

finishVmMigration

protected void finishVmMigration(SimEvent evt, boolean ack)

Finishes the process of migrating a VM.

Parameters:
  • evt – information about the event just happened
  • ack – indicates if the event’s sender expects to receive an acknowledge message when the event finishes to be processed

getBandwidthPercentForMigration

public double getBandwidthPercentForMigration()

getCharacteristics

public DatacenterCharacteristics getCharacteristics()

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 the getSchedulingInterval() 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), or Double.MAX_VALUE if there is no next Cloudlet to execute
Returns:

next time cloudlets processing will be updated

See also: .updateCloudletProcessing()

getDatacenterStorage

public DatacenterStorage getDatacenterStorage()

getHost

public Host getHost(int index)

getHostById

public Host getHostById(long id)

getHostList

public <T extends Host> List<T> getHostList()

getLastProcessTime

protected double getLastProcessTime()

Gets the last time some cloudlet was processed in the Datacenter.

Returns:the last process time

getPower

public double getPower()

getSchedulingInterval

public double getSchedulingInterval()

getVmAllocationPolicy

public VmAllocationPolicy getVmAllocationPolicy()

getVmList

public <T extends Vm> List<T> getVmList()

hashCode

public int hashCode()

isMigrationsEnabled

public boolean isMigrationsEnabled()

Checks if migrations are enabled.

Returns:true, if migrations are enable; false otherwise

processCloudlet

protected void processCloudlet(SimEvent evt, int type)

Processes a Cloudlet based on the event type.

Parameters:
  • evt – information about the event just happened
  • type – event type

processCloudletCancel

protected void processCloudletCancel(Cloudlet cloudlet)

Processes a Cloudlet cancel request.

Parameters:
  • cloudlet – cloudlet to be canceled

processCloudletPause

protected void processCloudletPause(Cloudlet cloudlet, boolean ack)

Processes a Cloudlet pause request.

Parameters:
  • cloudlet – cloudlet to be paused
  • ack – indicates if the event’s sender expects to receive an acknowledge message when the event finishes to be processed

processCloudletResume

protected void processCloudletResume(Cloudlet cloudlet, boolean ack)

Processes a Cloudlet resume request.

Parameters:
  • cloudlet – cloudlet to be resumed
  • ack – indicates if the event’s sender expects to receive an acknowledge message when the event finishes to be processed

processCloudletSubmit

protected void processCloudletSubmit(SimEvent evt, boolean ack)

Processes the submission of a Cloudlet by a DatacenterBroker.

Parameters:
  • evt – information about the event just happened
  • ack – indicates if the event’s sender expects to receive an acknowledge message when the event finishes to be processed

processEvent

public void processEvent(SimEvent evt)

processPingRequest

protected void processPingRequest(SimEvent evt)

Processes a ping request.

Parameters:
  • evt – information about the event just happened

processVmCreate

protected boolean processVmCreate(SimEvent evt, boolean ackRequested)

Process the event for a Broker which wants to create a VM in this Datacenter. This Datacenter will then send the status back to the Broker.

Parameters:
  • evt – information about the event just happened
  • ackRequested – indicates if the event’s sender expects to receive an acknowledge message when the event finishes to be processed
Returns:

true if a host was allocated to the VM; false otherwise

processVmDestroy

protected void processVmDestroy(SimEvent evt, boolean ack)

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
  • ack – indicates if the event’s sender expects to receive an acknowledge message when the event finishes to be processed

removeHost

public <T extends Host> Datacenter removeHost(T host)

setBandwidthPercentForMigration

public void setBandwidthPercentForMigration(double bandwidthPercentForMigration)

setDatacenterStorage

public final void setDatacenterStorage(DatacenterStorage datacenterStorage)

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

setSchedulingInterval

public final Datacenter setSchedulingInterval(double schedulingInterval)

setVmAllocationPolicy

public final Datacenter setVmAllocationPolicy(VmAllocationPolicy vmAllocationPolicy)

Sets the policy to be used by the Datacenter to allocate VMs into hosts.

Parameters:
  • vmAllocationPolicy – the new vm allocation policy

shutdownEntity

public void shutdownEntity()

startEntity

protected void startEntity()

toString

public String toString()

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