/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
import java.util.List;
/**
* CloudletScheduler is an abstract class that represents the policy of
* scheduling performed by a virtual machine. So, classes
* extending this must execute Cloudlets. Also, the interface for cloudlet
* management is also implemented in this class.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
*/
//表示VM执行的调度策略的抽象类。所以,继承该类的类必须执行cloudlet。同时,cloudlet的管理接口在该类实现。
public abstract class CloudletScheduler {
//先前时间
/** The previous time. */
private double previousTime;
//当前共享mips
/** The current mips share. */
private List<Double> currentMipsShare;
/**
* Creates a new CloudletScheduler object. This method must be invoked
* before starting the actual simulation.
*
* @pre $none
* @post $none
*/
//构造函数,需要在真正执行模拟器前调用该类
public CloudletScheduler() {
setPreviousTime(0.0);
}
/**
* Updates the processing of cloudlets running under management of this scheduler.
*
* @param currentTime current simulation time
* @param mipsShare array with MIPS share of each processor available to the scheduler
*
* @return time predicted completion time of the earliest finishing cloudlet, or 0
* if there is no next events
*
* @pre currentTime >= 0
* @post $none
*/
//更新该调度器管理下的cloudlet的处理
public abstract double updateVmProcessing(double currentTime, List<Double> mipsShare);
/**
* Receives an cloudlet to be executed in the VM managed by this scheduler.
*
* @param gl the submited cloudlet
* @param fileTransferTime time required to move the required files from the SAN to the VM
*
* @return expected finish time of this cloudlet, or 0 if it is in a waiting queue
*
* @pre gl != null
* @post $none
*/
//收到要在该调度器管理下的VM上运行的cloudlet
public abstract double cloudletSubmit(Cloudlet gl, double fileTransferTime);
/**
* Receives an cloudlet to be executed in the VM managed by this scheduler.
*
* @param gl the submited cloudlet
*
* @return expected finish time of this cloudlet, or 0 if it is in a waiting queue
*
* @pre gl != null
* @post $none
*/
//收到要在该调度器管理下的VM上运行的cloudlet
public abstract double cloudletSubmit(Cloudlet gl);
/**
* Cancels execution of a cloudlet.
*
* @param clId ID of the cloudlet being cancealed
*
* @return the canceled cloudlet, $null if not found
*
* @pre $none
* @post $none
*/
//取消某个cloudlet的运行
public abstract Cloudlet cloudletCancel(int clId);
/**
* Pauses execution of a cloudlet.
*
* @param clId ID of the cloudlet being paused
*
* @return $true if cloudlet paused, $false otherwise
*
* @pre $none
* @post $none
*/
//暂停某个cloudlet的运行
public abstract boolean cloudletPause(int clId);
/**
* 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
*/
//恢复某个cloudlet的运行
public abstract double cloudletResume(int clId);
/**
* Processes a finished cloudlet.
*
* @param rcl finished cloudlet
*
* @pre rgl != $null
* @post $none
*/
//处理某个完成的cloudlet
public abstract void cloudletFinish(ResCloudlet rcl);
/**
* Gets the status of a cloudlet.
*
* @param clId ID of the cloudlet
*
* @return status of the cloudlet, -1 if cloudlet not found
*
* @pre $none
* @post $none
*/
//获取某个cloudlet的状态
public abstract int getCloudletStatus(int clId);
/**
* Informs about completion of some cloudlet in the VM managed
* by this scheduler.
*
* @return $true if there is at least one finished cloudlet; $false otherwise
*
* @pre $none
* @post $none
*/
//判断该VM的所有cloudlets是否完成
public abstract boolean isFinishedCloudlets();
/**
* Returns the next cloudlet in the finished list, $null if this list is empty.
*
* @return a finished cloudlet
*
* @pre $none
* @post $none
*/
//获取finished list中的下一个cloudlet
public abstract Cloudlet getNextFinishedCloudlet();
/**
* Returns the number of cloudlets runnning in the virtual machine.
*
* @return number of cloudlets runnning
*
* @pre $none
* @post $none
*/
//获取VM上的cloudlet数量
public abstract int runningCloudlets();
/**
* Returns one cloudlet to migrate to another vm.
*
* @return one running cloudlet
*
* @pre $none
* @post $none
*/
//cloudlet从一个vm迁移到另一个
public abstract Cloudlet migrateCloudlet();
/**
* Get utilization created by all cloudlets.
*
* @param time the time
*
* @return total utilization
*/
//获取所有cloudlet设置的使用率
public abstract double getTotalUtilizationOfCpu(double time);
/**
* Gets the current requested mips.
*
* @return the current mips
*/
//获取当前请求的mips
public abstract List<Double> getCurrentRequestedMips();
/**
* Gets the total current mips for the Cloudlet.
*
* @param rcl the rcl
* @param mipsShare the mips share
*
* @return the total current mips
*/
//获取cloudlet的总mips
public abstract double getTotalCurrentAvailableMipsForCloudlet(ResCloudlet rcl, List<Double> mipsShare);
/**
* Gets the total current requested mips for cloudlet.
*
* @param rcl the rcl
* @param time the time
*
* @return the total current requested mips for cloudlet
*/
//获取cloudlet当前总请求mips
public abstract double getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl, double time);
/**
* Gets the total current allocated mips for cloudlet.
*
* @param rcl the rcl
* @param time the time
*
* @return the total current allocated mips for cloudlet
*/
//获取cloudlet当前总得到的mips
public abstract double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time);
/**
* Gets the previous time.
*
* @return the previous time
*/
//获取previous时间
public double getPreviousTime() {
return previousTime;
}
/**
* Sets the previous time.
*
* @param previousTime the new previous time
*/
//设置previous时间
protected void setPreviousTime(double previousTime) {
this.previousTime = previousTime;
}
/**
* Sets the current mips share.
*
* @param currentMipsShare the new current mips share
*/
//设置当前共享mips
protected void setCurrentMipsShare(List<Double> currentMipsShare) {
this.currentMipsShare = currentMipsShare;
}
/**
* Gets the current mips share.
*
* @return the current mips share
*/
//获取当前共享mips
public List<Double> getCurrentMipsShare() {
return currentMipsShare;
}
}
cloudSim源代码学习:cloudletScheduler.java
最新推荐文章于 2022-03-23 16:35:35 发布