Class CloudletSchedulerAbstract
- All Implemented Interfaces:
Serializable,CloudletScheduler
- Direct Known Subclasses:
CloudletSchedulerSpaceShared,CloudletSchedulerTimeShared
CloudletSchedulers representing
scheduling policies performed by a Vm to run its
Cloudlets. Each VM must have its own instance of a CloudletScheduler.- Since:
- CloudSim Toolkit 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
- See Also:
-
Field Summary
Fields inherited from interface org.cloudsimplus.schedulers.cloudlet.CloudletScheduler
LOGGER, NULL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds a Cloudlet to the list of cloudlets in execution.voidaddCloudletToReturnedList(Cloudlet cloudlet) Adds a Cloudlet to the list of finished Cloudlets that have been returned to itsDatacenterBroker.protected voidaddOnCloudletResourceAllocationFail(EventListener<CloudletResourceAllocationFailEventInfo> listener) Adds a listener object that will be notified every time aCloudletScheduleris not able to allocate the amount of resource aCloudletis requesting, due to lack of available capacity.protected CloudletExecutionRemoves a Cloudlet from the waiting list and adds it to the exec list.protected abstract booleanvoidclear()Clears the internal state of the schedulercloudletCancel(Cloudlet cloudlet) Cancels the execution of a cloudlet.protected doublecloudletEstimatedFinishTime(CloudletExecution cle, double currentTime) Gets the estimated time when a given cloudlet is supposed to finish executing.cloudletFail(Cloudlet cloudlet) Sets a cloudlet as failed.protected voidProcesses a finished cloudlet.booleancloudletPause(Cloudlet cloudlet) Pauses the execution of a cloudlet.booleancloudletReady(Cloudlet cloudlet) Sets the status of a Cloudlet toCloudlet.Status.READYso that it can start executing as soon as possible.final doublecloudletSubmit(Cloudlet cloudlet) Receives a cloudlet to be executed in the VM managed by this scheduler.final doublecloudletSubmit(Cloudlet cloudlet, double fileTransferTime) Receives a cloudlet to be executed in the VM managed by this scheduler.protected doublecloudletSubmitInternal(CloudletExecution cle, double fileTransferTime) Receives the execution information of a Cloudlet to be executed in the VM managed by this scheduler.voiddeallocatePesFromVm(long pesToRemove) Releases a given number of PEs from a VM.Enables the history of all Cloudlets submitted so far.protected Optional<CloudletExecution> findCloudletInAllLists(double cloudletId) Search for a Cloudlet into all Cloudlet lists.protected Optional<CloudletExecution> findCloudletInList(Cloudlet cloudlet, List<CloudletExecution> list) Search for a Cloudlet into a given list.protected Optional<CloudletExecution> 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.doublegetAllocatedCpuPercent(double time) Gets total CPU utilization percentage allocated (from MIPS capacity) to all cloudlets, according to CPUUtilizationModelof each Cloudlet.doublegetAllocatedMipsForCloudlet(CloudletExecution cle, double time) Gets the current allocated MIPS for a cloudlet.doublegetAllocatedMipsForCloudlet(CloudletExecution cle, double time, boolean log) Gets the current allocated MIPS for cloudlet.doubleGets 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.Returns a read-only list of Cloudlets that finished executing and were returned to the broker.Gets the list of all Cloudlets submitted for a VM so far.doubleGets the current utilization percentage of Bandwidth that the running Cloudlets are requesting (in scale from 0 to 1).doubleGets the current utilization percentage of RAM that the running Cloudlets are requesting (in scale from 0 to 1).longdoublegetRequestedCpuPercent(double time) Gets total CPU percentage requested (from MIPS capacity) from all cloudlets, according to CPUUtilizationModelof each Cloudlet.protected doublegetRequestedMipsForCloudlet(CloudletExecution cle, double time) Gets the current requested MIPS for a given cloudlet.longbooleanInforms if there is any cloudlet that finished executing in the VM managed by this scheduler.booleanisEmpty()Checks if there aren't cloudlets waiting or executing inside the Vm.protected booleanChecks if the number of PEs required by a given Cloudlet is free to use.booleanChecks if there is aCloudletTaskSchedulerassigned to this CloudletScheduler to enable tasks execution and dispatching packets from and to the Vm of this CloudletScheduler.protected doublemoveNextCloudletsFromWaitingToExecList(double currentTime) Selects the next Cloudlets in the waiting list to move to the execution list to start executing them.protected CloudletExecutionRemoves a Cloudlet from the list of cloudlets in execution.booleanremoveOnCloudletResourceAllocationFail(EventListener<CloudletResourceAllocationFailEventInfo> listener) Removes a Listener object from the registered List.protected voidsetCurrentMipsShare(@NonNull MipsShare currentMipsShare) Sets current MIPS share available for the VM using the scheduler.final voidsetPreviousTime(double previousTime) Sets the previous time when the scheduler updated the processing of the cloudlets it is managing.voidsetTaskScheduler(CloudletTaskScheduler taskScheduler) Sets theCloudletTaskSchedulerto process cloudlet tasks namely (i) sending or receivingVmPackets by the Vm assigned to the current CloudletScheduler, or (ii) scheduling execution tasks.voidSets the Vm that will use this scheduler.protected voidsortCloudletWaitingList(Comparator<CloudletExecution> comparator) Sorts thecloudletWaitingListusing a givenComparator.protected doubleupdateCloudletProcessing(CloudletExecution cle, double currentTime) Updates the processing of a specific cloudlet from the Vm using this scheduler.doubleupdateProcessing(double currentTime, MipsShare mipsShare) Updates the processing of cloudlets inside the Vm running under management of this scheduler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cloudsimplus.schedulers.cloudlet.CloudletScheduler
cloudletResume, getCloudletFinishedList, getPreviousTime, getTaskScheduler, getVm, isCloudletSubmittedListEnabled
-
Constructor Details
-
CloudletSchedulerAbstract
protected CloudletSchedulerAbstract()Creates a CloudletScheduler.
-
-
Method Details
-
setPreviousTime
public final void setPreviousTime(double previousTime) Description copied from interface:CloudletSchedulerSets the previous time when the scheduler updated the processing of the cloudlets it is managing.- Specified by:
setPreviousTimein interfaceCloudletScheduler- Parameters:
previousTime- the new previous time
-
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 use, since 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 are available PEs to be used exclusively by them.
- Returns:
- the amount of available MIPS for each Processor PE.
-
getCloudletExecList
- Specified by:
getCloudletExecListin interfaceCloudletScheduler- Returns:
- a read-only List of cloudlets being executed on the VM.
-
getCloudletSubmittedList
Description copied from interface:CloudletSchedulerGets the list of all Cloudlets submitted for a VM so far. This can be used at the end of the simulation to know which Cloudlets have been sent to a VM.NOTE: The history in this List is just kept if
CloudletScheduler.enableCloudletSubmittedList()is called.- Specified by:
getCloudletSubmittedListin interfaceCloudletScheduler- Type Parameters:
T- the class of Cloudlets inside the list- Returns:
- the list of all submitted Cloudlets
-
enableCloudletSubmittedList
Description copied from interface:CloudletSchedulerEnables the history of all Cloudlets submitted so far.- Specified by:
enableCloudletSubmittedListin interfaceCloudletScheduler- See Also:
-
addCloudletToWaitingList
-
getCloudletWaitingList
- Specified by:
getCloudletWaitingListin interfaceCloudletScheduler- Returns:
- a read-only List of cloudlet waiting to be executed on the VM.
-
sortCloudletWaitingList
Sorts thecloudletWaitingListusing a givenComparator.- Parameters:
comparator- theComparatorto sort the Waiting Cloudlets List
-
cloudletSubmit
Description copied from interface:CloudletSchedulerReceives a cloudlet to be executed in the VM managed by this scheduler.- Specified by:
cloudletSubmitin interfaceCloudletScheduler- Parameters:
cloudlet- the submitted cloudlet- 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
-
cloudletSubmit
Description copied from interface:CloudletSchedulerReceives a cloudlet to be executed in the VM managed by this scheduler.- Specified by:
cloudletSubmitin interfaceCloudletScheduler- Parameters:
cloudlet- the submitted cloudletfileTransferTime- time to move the required files from the Datacenter 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
-
cloudletSubmitInternal
Receives the execution information of a Cloudlet to be executed in the VM managed by this scheduler.- Parameters:
cle- the submitted cloudletfileTransferTime- time required to move the required files from the SAN to the VM (in seconds)- 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:
-
addCloudletToExecList
Adds a Cloudlet to the list of cloudlets in execution.- Parameters:
cle- the Cloudlet to be added
-
hasFinishedCloudlets
public boolean hasFinishedCloudlets()Description copied from interface:CloudletSchedulerInforms if there is any cloudlet that finished executing in the VM managed by this scheduler.- Specified by:
hasFinishedCloudletsin interfaceCloudletScheduler- Returns:
- true if there is at least one finished cloudlet; false otherwise
-
findCloudletInAllLists
Search for a Cloudlet into all Cloudlet lists.- Parameters:
cloudletId- the id of the Cloudlet to search for- Returns:
- an
Optionalvalue 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 forlist- the list to search the Cloudlet into- Returns:
- an
Optionalvalue that is able to indicate if the Cloudlet was found or not
-
cloudletFinish
Processes a finished cloudlet.- Parameters:
cle- the finished cloudlet to process
-
cloudletReady
Description copied from interface:CloudletSchedulerSets the status of a Cloudlet toCloudlet.Status.READYso that it can start executing as soon as possible.- Specified by:
cloudletReadyin interfaceCloudletScheduler- Parameters:
cloudlet- the cloudlet to be started- Returns:
- true if cloudlet was set to ready, false otherwise
-
cloudletPause
Description copied from interface:CloudletSchedulerPauses the execution of a cloudlet.- Specified by:
cloudletPausein interfaceCloudletScheduler- Parameters:
cloudlet- the cloudlet being paused- Returns:
- true if cloudlet was paused, false otherwise
-
cloudletFail
Description copied from interface:CloudletSchedulerSets a cloudlet as failed.- Specified by:
cloudletFailin interfaceCloudletScheduler- Parameters:
cloudlet- cloudlet to set as failed- Returns:
- the failed cloudlet or
Cloudlet.NULLif not found
-
cloudletCancel
Description copied from interface:CloudletSchedulerCancels the execution of a cloudlet.- Specified by:
cloudletCancelin interfaceCloudletScheduler- Parameters:
cloudlet- the cloudlet being canceled- Returns:
- the canceled cloudlet or
Cloudlet.NULLif not found
-
updateCloudletProcessing
Updates the processing of a specific cloudlet from the Vm using this scheduler.- Parameters:
cle- the cloudlet to be its processing updatedcurrentTime- current simulation time- Returns:
- the next time to update the cloudlet processing (which is a relative delay from the current simulation time) This will be the delay incurred in cloudlet processing caused by (i) vMem usage or (ii) BW reduction due to oversubscription. If no delay is incurred, it returns the expected cloudlet completion time.
-
addOnCloudletResourceAllocationFail
public CloudletScheduler addOnCloudletResourceAllocationFail(EventListener<CloudletResourceAllocationFailEventInfo> listener) Description copied from interface:CloudletSchedulerAdds a listener object that will be notified every time aCloudletScheduleris not able to allocate the amount of resource aCloudletis requesting, due to lack of available capacity.- Specified by:
addOnCloudletResourceAllocationFailin interfaceCloudletScheduler- Parameters:
listener- the Listener to add- Returns:
- this scheduler
-
removeOnCloudletResourceAllocationFail
public boolean removeOnCloudletResourceAllocationFail(EventListener<CloudletResourceAllocationFailEventInfo> listener) Description copied from interface:CloudletSchedulerRemoves a Listener object from the registered List.- Specified by:
removeOnCloudletResourceAllocationFailin interfaceCloudletScheduler- Parameters:
listener- the Listener to remove- Returns:
- true if the Listener was removed, false otherwise
-
removeCloudletFromExecList
Removes a Cloudlet from the list of cloudlets in execution.- Parameters:
cle- the Cloudlet to be removed- Returns:
- the removed Cloudlet or
CloudletExecution.NULLif not found
-
cloudletEstimatedFinishTime
Gets the estimated time when a given cloudlet is supposed to finish executing. It considers the amount of Vm PES and the total of PEs required by all VMs running inside the VM.- Parameters:
cle- cloudlet to get the estimated finish timecurrentTime- current simulation time- Returns:
- the estimated finish time of the given cloudlet (which is a relative delay from the current simulation time)
-
moveNextCloudletsFromWaitingToExecList
protected double moveNextCloudletsFromWaitingToExecList(double currentTime) Selects the next Cloudlets in the waiting list to move to the execution list to start executing them. While there are enough free PEs, the method tries 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
updateProcessing(double,MipsShare).- Parameters:
currentTime- current simulation time- Returns:
- the next time to update the cloudlet processing (which is a relative delay from the current simulation time) This will be the delay incurred in cloudlet processing caused by (i) vMem usage or (ii) BW reduction due to oversubscription. If no delay is incurred, it returns the expected cloudlet completion time.
-
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
Optionalcontaining the found Cloudlet or an empty Optional otherwise
-
isThereEnoughFreePesForCloudlet
Checks if the number 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 number of free PEs, false otherwise
-
addWaitingCloudletToExecList
Removes a Cloudlet from the waiting list and adds it to the exec list.- Parameters:
cle- the cloudlet to add to the exec list- Returns:
- the given cloudlet
-
setVm
Description copied from interface:CloudletSchedulerSets the Vm that will use this scheduler. It is not required to manually set a Vm for the scheduler, since aVmsets itself to the scheduler when the scheduler is assigned to the Vm.- Specified by:
setVmin interfaceCloudletScheduler- Parameters:
vm- the Vm to set
-
getUsedPes
public long getUsedPes()- Specified by:
getUsedPesin interfaceCloudletScheduler- Returns:
- the number of currently used
Pe's.
-
getFreePes
public long getFreePes()- Specified by:
getFreePesin interfaceCloudletScheduler- Returns:
- the number of PEs currently not being used.
-
setTaskScheduler
Description copied from interface:CloudletSchedulerSets theCloudletTaskSchedulerto process cloudlet tasks namely (i) sending or receivingVmPackets by the Vm assigned to the current CloudletScheduler, or (ii) scheduling execution tasks. The Vm from the CloudletScheduler is also set to the CloudletTaskScheduler.This attribute usually doesn't need to be set manually. See the note at the
CloudletTaskSchedulerinterface for more details.- Specified by:
setTaskSchedulerin interfaceCloudletScheduler- Parameters:
taskScheduler- the CloudletTaskScheduler to set for this CloudletScheduler, orCloudletTaskScheduler.NULLif this scheduler will not deal with packets' transmission.
-
isThereTaskScheduler
public boolean isThereTaskScheduler()Description copied from interface:CloudletSchedulerChecks if there is aCloudletTaskSchedulerassigned to this CloudletScheduler to enable tasks execution and dispatching packets from and to the Vm of this CloudletScheduler.- Specified by:
isThereTaskSchedulerin interfaceCloudletScheduler- Returns:
- true if a CloudletTaskScheduler is assigned to this CloudletScheduler; false otherwise
-
getRequestedCpuPercent
public double getRequestedCpuPercent(double time) Description copied from interface:CloudletSchedulerGets total CPU percentage requested (from MIPS capacity) from all cloudlets, according to CPUUtilizationModelof each Cloudlet.- Specified by:
getRequestedCpuPercentin interfaceCloudletScheduler- Parameters:
time- the time to get the current CPU utilization- Returns:
- the total CPU percentage requested (in scale from 0 to 1, where 1 is 100%)
-
getAllocatedCpuPercent
public double getAllocatedCpuPercent(double time) Description copied from interface:CloudletSchedulerGets total CPU utilization percentage allocated (from MIPS capacity) to all cloudlets, according to CPUUtilizationModelof each Cloudlet.- Specified by:
getAllocatedCpuPercentin interfaceCloudletScheduler- Parameters:
time- the time to get the current CPU utilization- Returns:
- the total CPU utilization percentage allocated (in scale from 0 to 1, where 1 is 100%).
-
getRequestedMipsForCloudlet
Gets the current requested MIPS for a given cloudlet.- Parameters:
cle- the Cloudlet to get the requested MIPStime- the current simulation time- Returns:
- the current requested MIPS for the given cloudlet
-
getAllocatedMipsForCloudlet
Gets the current allocated MIPS for a cloudlet.- Parameters:
cle- the cloudlet to get the allocated MIPStime- the current simulation time- Returns:
- the current allocated mips for cloudlet
-
getAllocatedMipsForCloudlet
Gets the current allocated MIPS for cloudlet.- Parameters:
cle- the cloudlet to get the allocated MIPStime- the current simulation timelog- Indicate if a log should be issued when the requested resource is larger than the capacity- Returns:
- the current allocated mips for cloudlet
-
getCurrentRequestedBwPercentUtilization
public double getCurrentRequestedBwPercentUtilization()Description copied from interface:CloudletSchedulerGets the current utilization percentage of Bandwidth that the running Cloudlets are requesting (in scale from 0 to 1).- Specified by:
getCurrentRequestedBwPercentUtilizationin interfaceCloudletScheduler- Returns:
- the BW utilization percentage from 0 to 1 (where 1 is 100%)
-
getCurrentRequestedRamPercentUtilization
public double getCurrentRequestedRamPercentUtilization()Description copied from interface:CloudletSchedulerGets the current utilization percentage of RAM that the running Cloudlets are requesting (in scale from 0 to 1).- Specified by:
getCurrentRequestedRamPercentUtilizationin interfaceCloudletScheduler- Returns:
- the RAM utilization percentage from 0 to 1 (where 1 is 100%)
-
getCloudletReturnedList
Returns a read-only list of Cloudlets that finished executing and were returned to the broker. A Cloudlet is returned to notify the broker about the end of its execution.- Returns:
- a read-only list of Cloudlets that finished executing and were returned to the broker
-
addCloudletToReturnedList
Description copied from interface:CloudletSchedulerAdds a Cloudlet to the list of finished Cloudlets that have been returned to itsDatacenterBroker.- Specified by:
addCloudletToReturnedListin interfaceCloudletScheduler- Parameters:
cloudlet- the Cloudlet to be added
-
deallocatePesFromVm
public void deallocatePesFromVm(long pesToRemove) Description copied from interface:CloudletSchedulerReleases a given number of PEs from a VM.- Specified by:
deallocatePesFromVmin interfaceCloudletScheduler- Parameters:
pesToRemove- number of PEs to deallocate
-
getCloudletList
- Specified by:
getCloudletListin interfaceCloudletScheduler- Returns:
- a read-only List of all cloudlets that are either waiting or executing on the VM.
-
isEmpty
public boolean isEmpty()Description copied from interface:CloudletSchedulerChecks if there aren't cloudlets waiting or executing inside the Vm.- Specified by:
isEmptyin interfaceCloudletScheduler- Returns:
- true if the scheduler has no cloudlets to execute or waiting to be executed; false otherwise
-
canExecuteCloudletInternal
- See Also:
-
clear
public void clear()Description copied from interface:CloudletSchedulerClears the internal state of the scheduler- Specified by:
clearin interfaceCloudletScheduler
-