CloudletScheduler 类
简介
CloudletScheduler 是一个核心组件,在云计算仿真环境中,它负责定义虚拟机(VM)如何调度和执行其Cloudlets(云任务)。
-
抽象类:CloudletScheduler 是一个抽象类,这意味着它不能直接实例化,而是需要通过子类来实现具体的功能。
-
调度策略:这个类代表了虚拟机用来运行其Cloudlets的调度策略。调度策略决定了Cloudlets如何在虚拟机上分配和执行,包括它们如何共享或分配CPU时间、处理元素(PE)等资源。
-
执行Cloudlets:任何扩展 CloudletScheduler 类的子类都必须实现执行Cloudlets的功能。这意味着子类需要提供具体的逻辑来管理Cloudlets的执行,包括开始、暂停、恢复和结束Cloudlets。
-
Cloudlet管理接口:CloudletScheduler 类还实现了Cloudlet管理的接口。这可能包括添加、删除、更新和查询Cloudlets状态的方法,以及可能的其他管理功能。
-
每个VM的实例:每个虚拟机都需要有自己的 CloudletScheduler 实例。这是因为每个虚拟机可能有不同的资源和调度需求,因此需要独立的调度器来管理其Cloudlets。
CloudletScheduler 类是云计算仿真工具(如CloudSim)中的一个关键组件,它允许开发者模拟和研究不同的调度策略,以优化资源使用效率、减少任务执行时间、提高系统吞吐量等。通过扩展这个抽象类,开发者可以创建自定义的调度器,以适应特定的应用场景或研究目标。
其他的类如
CloudletSchedulerDynamicWorkload 链接
CloudletSchedulerSpaceShared链接
CloudletSchedulerTimeShared 链接
继承自它
类属性
之前的运行时间
/** The previous time. */private double previousTime;
当前可用的计算频率列表
/** The list of current mips share available for the VM using the scheduler.* It is provided by {@link CloudletScheduler#updateCloudletsProcessing(double, List)} method.* at every simulation step. */private List<Double> currentMipsShare;
获得可用的计算能力
private double currentCapacity;
等待队列
/** The list of cloudlet waiting to be executed on the VM. */protected List<? extends Cloudlet> cloudletWaitingList;
正在执行的任务
/** The list of cloudlets being executed on the VM. */protected List<? extends Cloudlet> cloudletExecList;
暂停的任务
/** The list of paused cloudlets. */protected List<? extends Cloudlet> cloudletPausedList;
已经完成的任务
/** The list of finished cloudlets. */protected List<? extends Cloudlet> cloudletFinishedList;
失败的任务
/** The list of failed cloudlets. */protected List<? extends Cloudlet> cloudletFailedList;
最近完成的任务
/** Buffer list of the latest finished cloudlets. */protected List<Cloudlet> cloudletJustFinishedList;
类方法
初始化
/*** Creates a new CloudletScheduler object. * A CloudletScheduler must be created before starting the actual simulation.* * @pre $none* @post $none*/public CloudletScheduler()
更新运行时间
/*** Updates the processing of cloudlets running under management of this scheduler.* * @param currentTime current simulation time* @param mipsShare list with MIPS share of each Pe available to the scheduler* @return the predicted completion time of the earliest finishing cloudlet, * or 0 if there is no next events* @pre currentTime >= 0* @post $none*/public double updateCloudletsProcessing(double currentTime, List<Double> mipsShare)@Deprecatedpublic double updateVmProcessing(double currentTime, List<Double> mipsShare)
更新正在等待的任务
/*** Update the cloudlets currently waiting to execute.* The default implementation (i.e., no-op) is suitable for time-shared scheduling.** @param currentTime current simulation time* @param info info Any data you may need to implement the update logic*/protected void updateWaitingCloudlets(double currentTime, Object info)/*** Receives a cloudlet to be executed in the VM managed by this scheduler.* * @param cl the submitted cloudlet* @return expected finish time of this cloudlet, or 0 if it is in a waiting queue* @pre gl != null* @post $none*/public double cloudletSubmit(Cloudlet cl)
取消任务的执行
/*** Cancels execution of a cloudlet.* * @param cloudletId ID of the cloudlet being canceled* @return the canceled cloudlet, $null if not found* @pre $none* @post $none*/public Cloudlet cloudletCancel(final int cloudletId)
暂停一个任务的执行
/*** Pauses execution of a cloudlet.* * @param cloudletId ID of the cloudlet being paused* @return $true if cloudlet paused, $false otherwise* @pre $none* @post $none*/public boolean cloudletPause(int cloudletId)
回复一个暂停的任务
/*** Resumes execution of a paused cloudlet.* * @param clId ID of the cloudlet being resumed* @return expected finish time of the cloudlet, 0.0 if queued* @pre $none* @post $none*/public abstract double cloudletResume(int clId);
完成任务
/*** Processes a finished cloudlet.* * @param cl finished cloudlet* @pre rgl != $null* @post $none*/public void cloudletFinish(Cloudlet cl)
得到当前任务的状态
/*** Gets the status of a cloudlet.* * @param cloudletId ID of the cloudlet* @return status of the cloudlet, -1 if cloudlet not found* @pre $none* @post $none**/public Cloudlet.CloudletStatus getCloudletStatus(final int cloudletId)
检查是否有已经完成的任务
/*** Informs if there is any cloudlet that finished to execute in the VM managed by this scheduler.* * @return $true if there is at least one finished cloudlet; $false otherwise* @pre $none* @post $none* //TODO the method name would be isThereFinishedCloudlets to be clearer*/public boolean isFinishedCloudlets()
返回下一个完成的任务
/*** Returns the next cloudlet in the finished list.* * @return a finished cloudlet or $null if the respective list is empty* @pre $none* @post $none*/public Cloudlet getNextFinishedCloudlet()
返回虚拟机中运行的任务
/*** Returns the number of cloudlets running in the virtual machine.* * @return number of cloudlets running* @pre $none* @post $none*/public int runningCloudlets()
返回一个任务进行任务迁移
/*** Returns one cloudlet to migrate to another vm.* * @return one running cloudlet* @pre $none* @post $none** @TODO: Remo Andreoli: No clue why it's removing the first element*/public Cloudlet migrateCloudlet()
获得任务的预计完成时间
/*** Get the estimated completion time of a given cloudlet.** @param cl the cloudlet* @param time the time* @return the estimated finish time*/public double getEstimatedFinishTime(Cloudlet cl, double time)
获得总CPU利用率
/*** Gets total CPU utilization percentage of all cloudlets, according to CPU UtilizationModel of * each one.* * @param time the time to get the current CPU utilization* @return total utilization*/public double getTotalUtilizationOfCpu(double time)
获得当前的请求频率(分内核)
/*** Gets the current requested mips.* * @return the current mips*/public List<Double> getCurrentRequestedMips()
获得总请求计算量
/*** Gets the total of the current requested mips.* * @return the current mips*/public double getCurrentRequestedTotalMips()
获得当前总可用的计算能力
/*** Gets the total current available mips for the Cloudlet.* * @param rcl the rcl* @param mipsShare the mips share* @return the total current mips* //TODO In fact, this method is returning different data depending* of the subclass. It is expected that the way the method use to compute* the resulting value can be different in every subclass,* but is not supposed that each subclass returns a complete different * result for the same method of the superclass.* In some class such as NetworkCloudletSpaceSharedScheduler (OLD CLASS),* the method returns the average MIPS for the available PEs,* in other classes such as {@link CloudletSchedulerDynamicWorkload} it returns* the MIPS' sum of all PEs.*/public abstract double getTotalCurrentAvailableMipsForCloudlet(Cloudlet rcl, List<Double> mipsShare);
获得当前总请求的计算能力
/*** Gets the total current requested mips for a given cloudlet.* * @param cl the cloudlet* @param time the time* @return the total current requested mips for the given cloudlet*/public abstract double getTotalCurrentRequestedMipsForCloudlet(Cloudlet cl, double time);
获得当前分配给任务的计算能力
/*** Gets the total current allocated mips for cloudlet.* * @param cl the cloudlet* @param time the time* @return the total current allocated mips for cloudlet*/public abstract double getTotalCurrentAllocatedMipsForCloudlet(Cloudlet cl, double time);
当前请求的内存
/*** Gets the current requested ram.* * @return the current requested ram*/public double getCurrentRequestedUtilizationOfRam()
获得当前请求的带宽
/*** Gets the current requested bw.* * @return the current requested bw*/public double getCurrentRequestedUtilizationOfBw()
获得之前的运行时间
/*** Gets the previous time.* * @return the previous time*/public double getPreviousTime()
设置之前的运行时间
/*** Sets the previous time.* * @param previousTime the new previous time*/protected void setPreviousTime(double previousTime)
设置计算资源的分配情况
/*** Sets the current mips share.* * @param currentMipsShare the new current mips share*/protected void setCurrentMipsShare(List<Double> currentMipsShare)
获得可用的核心数
/*** The number of PEs currently available for the VM using the scheduler,* according to the current mips share provided*/public int getCurrentPEs()
计算任务可用的计算量
/** Get the individual MIPS capacity available for each cloudlet, according to the number of* available PE provided by the current mip share.*/public double getCurrentCapacity()
更新任务可用的计算量
/*** ASSUMPTION: all PEs have the same capacity.* @return capacity*/public double updateCurrentCapacity()@Deprecatedprotected double getCapacity(List<Double> mipsShare)
得到等待的任务队列
/*** Gets the cloudlet waiting list.* * @param <T> the generic type* @return the cloudlet waiting list*/@SuppressWarnings("unchecked")public <T extends Cloudlet> List<T> getCloudletWaitingList()
设置任务等待队列
/*** Cloudlet waiting list.* * @param <T> the generic type* @param cloudletWaitingList the cloudlet waiting list*/protected <T extends Cloudlet> void setCloudletWaitingList(List<T> cloudletWaitingList)
得到任务执行队列
/*** Gets the cloudlet exec list.* * @param <T> the generic type* @return the cloudlet exec list*/@SuppressWarnings("unchecked")public <T extends Cloudlet> List<T> getCloudletExecList()
设置任务执行队列
/*** Sets the cloudlet exec list.* * @param <T> the generic type* @param cloudletExecList the new cloudlet exec list*/protected <T extends Cloudlet> void setCloudletExecList(List<T> cloudletExecList)
得到任务暂停队列
/*** Gets the cloudlet paused list.* * @param <T> the generic type* @return the cloudlet paused list*/@SuppressWarnings("unchecked")public <T extends Cloudlet> List<T> getCloudletPausedList()
设置任务暂停队列
/*** Sets the cloudlet paused list.* * @param <T> the generic type* @param cloudletPausedList the new cloudlet paused list*/protected <T extends Cloudlet> void setCloudletPausedList(List<T> cloudletPausedList)
得到任务完成队列
/*** Gets the cloudlet finished list.* * @param <T> the generic type* @return the cloudlet finished list*/@SuppressWarnings("unchecked")public <T extends Cloudlet> List<T> getCloudletFinishedList()
设置任务完成队列
/*** Sets the cloudlet finished list.* * @param <T> the generic type* @param cloudletFinishedList the new cloudlet finished list*/protected <T extends Cloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList)
得到任务失败队列
/*** Gets the cloudlet failed list.* * @param <T> the generic type* @return the cloudlet failed list.*/@SuppressWarnings("unchecked")public <T extends Cloudlet> List<T> getCloudletFailedList()
设置任务失败队列
/*** Sets the cloudlet failed list.* * @param <T> the generic type* @param cloudletFailedList the new cloudlet failed list.*/protected <T extends Cloudlet> void setCloudletFailedList(List<T> cloudletFailedList)