CloudletSchedulerAbstract

public abstract class CloudletSchedulerAbstract implements CloudletScheduler

Implements the basic features of a CloudletScheduler, representing the policy of scheduling performed by a virtual machine to run its Cloudlets. So, classes extending this must execute Cloudlets. The interface for cloudlet management is also implemented in this class. Each VM has to have its own instance of a CloudletScheduler.

Author:Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho

Constructors

CloudletSchedulerAbstract

protected CloudletSchedulerAbstract()

Creates a new CloudletScheduler object.

Methods

addCloudletToExecList

protected void addCloudletToExecList(CloudletExecution cle)

Adds a Cloudlet to the list of cloudlets in execution.

Parameters:
  • cle – the Cloudlet to be added

addCloudletToReturnedList

public void addCloudletToReturnedList(Cloudlet cloudlet)

addCloudletToWaitingList

protected void addCloudletToWaitingList(CloudletExecution cle)

addWaitingCloudletToExecList

protected CloudletExecution addWaitingCloudletToExecList(CloudletExecution cle)

Removes a Cloudlet from waiting list and adds it to the exec list.

Parameters:
  • cle – the cloudlet to add to to exec list
Returns:

the given cloudlet

canExecuteCloudletInternal

protected abstract boolean canExecuteCloudletInternal(CloudletExecution cle)

See also: .canExecuteCloudlet(CloudletExecution)

cloudletCancel

public Cloudlet cloudletCancel(Cloudlet cloudlet)

cloudletFail

public Cloudlet cloudletFail(Cloudlet cloudlet)

cloudletFinish

public void cloudletFinish(CloudletExecution cle)

cloudletPause

public boolean cloudletPause(Cloudlet cloudlet)

cloudletReady

public boolean cloudletReady(Cloudlet cloudlet)

cloudletSubmit

public final double cloudletSubmit(Cloudlet cloudlet)

cloudletSubmit

public final double cloudletSubmit(Cloudlet cloudlet, double fileTransferTime)

cloudletSubmitInternal

protected double cloudletSubmitInternal(CloudletExecution cle, double fileTransferTime)

Receives the execution information of a Cloudlet to be executed in the VM managed by this scheduler.

Parameters:
  • cle – the submitted cloudlet
  • fileTransferTime – time required to move the required files from the SAN to the VM
Returns:

expected finish time of this cloudlet (considering the time to transfer required files from the Datacenter to the Vm), or 0 if it is in a waiting queue

See also: .cloudletSubmit(Cloudlet,double)

deallocatePesFromVm

public void deallocatePesFromVm(int pesToRemove)

findCloudletInAllLists

protected Optional<CloudletExecution> findCloudletInAllLists(double cloudletId)

Search for a Cloudlet into all Cloudlet lists.

Parameters:
  • cloudletId – the id of the Cloudlet to search for
Returns:

an Optional value that is able to indicate if the Cloudlet was found or not

findCloudletInList

protected Optional<CloudletExecution> findCloudletInList(Cloudlet cloudlet, List<CloudletExecution> list)

Search for a Cloudlet into a given list.

Parameters:
  • cloudlet – the Cloudlet to search for
  • list – the list to search the Cloudlet into
Returns:

an Optional value that is able to indicate if the Cloudlet was found or not

findSuitableWaitingCloudlet

protected Optional<CloudletExecution> findSuitableWaitingCloudlet()

Try to find the first Cloudlet in the waiting list that the number of required PEs is not higher than the number of free PEs.

Returns:an Optional containing the found Cloudlet or an empty Optional otherwise

getAllocatedMipsForCloudlet

public double getAllocatedMipsForCloudlet(CloudletExecution cle, double time)

Gets the current allocated MIPS for cloudlet.

Parameters:
  • cle – the ce
  • time – the time
Returns:

the current allocated mips for cloudlet

getAvailableMipsByPe

public double getAvailableMipsByPe()

Gets the amount of MIPS available (free) for each Processor PE, considering the currently executing cloudlets in this processor and the number of PEs these cloudlets require. This is the amount of MIPS that each Cloudlet is allowed to used, considering that the processor is shared among all executing cloudlets.

In the case of space shared schedulers, there is no concurrency for PEs because some cloudlets may wait in a queue until there is available PEs to be used exclusively by them.

Returns:the amount of available MIPS for each Processor PE.

getCloudletExecList

public List<CloudletExecution> getCloudletExecList()

getCloudletFailedList

protected List<CloudletExecution> getCloudletFailedList()

Gets the list of failed cloudlets.

Returns:the cloudlet failed list.

getCloudletFinishedList

public List<CloudletExecution> getCloudletFinishedList()

getCloudletList

public List<Cloudlet> getCloudletList()

getCloudletPausedList

protected List<CloudletExecution> getCloudletPausedList()

Gets the list of paused cloudlets.

Returns:the cloudlet paused list

getCloudletReturnedList

public Set<Cloudlet> getCloudletReturnedList()

getCloudletStatus

public int getCloudletStatus(int cloudletId)

getCloudletToMigrate

public Cloudlet getCloudletToMigrate()

Returns the first cloudlet in the execution list to migrate to another VM, removing it from the list.

Returns:the first executing cloudlet or Cloudlet.NULL if the executing list is empty

getCloudletWaitingList

public List<CloudletExecution> getCloudletWaitingList()

getCurrentMipsShare

public List<Double> getCurrentMipsShare()

Gets a read-only list of current mips capacity from the VM that will be made available to the scheduler. This mips share will be allocated to Cloudlets as requested.

Returns:the current mips share list, where each item represents the MIPS capacity of a Pe. that is available to the scheduler.

getCurrentRequestedBwPercentUtilization

public double getCurrentRequestedBwPercentUtilization()

getCurrentRequestedRamPercentUtilization

public double getCurrentRequestedRamPercentUtilization()

getEstimatedFinishTimeOfCloudlet

protected double getEstimatedFinishTimeOfCloudlet(CloudletExecution cle, double currentTime)

Gets the estimated time when a given cloudlet is supposed to finish executing. It considers the amount of Vm PES and the sum of PEs required by all VMs running inside the VM.

Parameters:
  • cle – cloudlet to get the estimated finish time
  • currentTime – current simulation time
Returns:

the estimated finish time of the given cloudlet (which is a relative delay from the current simulation time)

getEstimatedFinishTimeOfSoonerFinishingCloudlet

protected double getEstimatedFinishTimeOfSoonerFinishingCloudlet(double currentTime)

Gets the estimated time, considering the current time, that a next Cloudlet is expected to finish.

Parameters:
  • currentTime – current simulation time
Returns:

the estimated finish time of sooner finishing cloudlet (which is a relative delay from the current simulation time)

getFreePes

public long getFreePes()

Gets the number of PEs currently not being used.

getPreviousTime

public double getPreviousTime()

getRequestedCpuPercentUtilization

public double getRequestedCpuPercentUtilization(double time)

getRequestedMipsForCloudlet

public double getRequestedMipsForCloudlet(CloudletExecution cle, double time)

getTaskScheduler

public CloudletTaskScheduler getTaskScheduler()

getUsedPes

public long getUsedPes()

getVm

public Vm getVm()

hasFinishedCloudlets

public boolean hasFinishedCloudlets()

isCloudletReturned

public boolean isCloudletReturned(Cloudlet cloudlet)

isEmpty

public boolean isEmpty()

isThereEnoughFreePesForCloudlet

protected boolean isThereEnoughFreePesForCloudlet(CloudletExecution cle)

Checks if the amount of PEs required by a given Cloudlet is free to use.

Parameters:
  • cle – the Cloudlet to get the number of required PEs
Returns:

true if there is the amount of free PEs, false otherwise

isThereTaskScheduler

public boolean isThereTaskScheduler()

moveNextCloudletsFromWaitingToExecList

protected void moveNextCloudletsFromWaitingToExecList()

Selects the next Cloudlets in the waiting list to move to the execution list in order to start executing them. While there is enough free PEs, the method try to find a suitable Cloudlet in the list, until it reaches the end of such a list.

The method might also exchange some cloudlets in the execution list with some in the waiting list. Thus, some running cloudlets may be preempted to give opportunity to previously waiting cloudlets to run. This is a process called context switch. However, each CloudletScheduler implementation decides how such a process is implemented. For instance, Space-Shared schedulers may perform context switch just after the currently running Cloudlets completely finish executing.

This method is called internally by the CloudletScheduler.updateProcessing(double,List).

removeCloudletFromExecList

protected CloudletExecution removeCloudletFromExecList(CloudletExecution cle)

Removes a Cloudlet from the list of cloudlets in execution.

Parameters:
  • cle – the Cloudlet to be removed
Returns:

the removed Cloudlet or CloudletExecution.NULL if not found

runningCloudletsNumber

public int runningCloudletsNumber()

setCurrentMipsShare

protected void setCurrentMipsShare(List<Double> currentMipsShare)

Sets the list of current mips share available for the VM using the scheduler.

Parameters:
  • currentMipsShare – the new current mips share

See also: .getCurrentMipsShare()

setPreviousTime

protected final void setPreviousTime(double previousTime)

Sets the previous time when the scheduler updated the processing of cloudlets it is managing.

Parameters:
  • previousTime – the new previous time

setTaskScheduler

public void setTaskScheduler(CloudletTaskScheduler taskScheduler)

setVm

public void setVm(Vm vm)

sortCloudletWaitingList

protected void sortCloudletWaitingList(Comparator<CloudletExecution> comparator)

Sorts the cloudletWaitingList using a given Comparator.

Parameters:
  • comparator – the Comparator to sort the Waiting Cloudlets List

timeSpan

protected double timeSpan(CloudletExecution cle, double currentTime)

Computes the time span between the current simulation time and the last time the processing of a cloudlet was updated.

Parameters:
  • cle – the cloudlet to compute the execution time span
  • currentTime – the current simulation time

updateCloudletProcessing

protected long updateCloudletProcessing(CloudletExecution cle, double currentTime)

Updates the processing of a specific cloudlet of the Vm using this scheduler.

Parameters:
  • cle – The cloudlet to be its processing updated
  • currentTime – current simulation time
Returns:

the executed length, in Million Instructions (MI), since the last time cloudlet was processed.

updateProcessing

public double updateProcessing(double currentTime, List<Double> mipsShare)