CloudSim基础仿真流程总结
这是在阅读CloudSim Example1用例代码后,对CloudSim仿真流程的一点总结
类
类总结:
- DataCenter类 数据中心,提供虚拟化网络资源 (封装了一系列的主机Hosts,并且必须保证每个数据中心至少创建一个Host) 此外,每个数据中心组件会实例化一个通用的应用调度组件,改组爱你实现了一系列的策略为主机和虚拟机分配带宽、内存和存储/
- DataCenterBroker类 代理,用于提交虚拟机列表和云任务列表(虚拟机和云应用在内的资源)代表了SaaS提供商。
- DataCenterCharacteristics类 包含数据中心资源的配置信息
- Host类 主机(物理机),扩展了对虚拟机的参数分配策略,一台Host可以对应多台VM
- VM类 虚拟机类,运行在Host上,与其他虚拟机共享资源
- VmAllocationPolicy 代表虚拟机监视器使用的调度策略,该策略用于将虚拟机分配给主机。主要功能:在数据中心选择一个满足条件(内存、存储容量和可用性)的可用主机,提供给需要部署的虚拟机。
- VmSheduler 有一个主机组件实现,模拟为虚拟机分布处理核所用的策略(空间共享和时间共享)。该类方法容易重写,以调整特定的处理器共享策略。
- Cloudlet类 云任务类,构建云环境任务. 每个应用服务都拥有一个预分配的指令长度和其生命周期内所需的数据传输开销。
- BwProvisioner 这一抽象类用于模拟虚拟机的带宽分配策略。研究员通过扩展这个类反应应用需求变化(基于优先级或者服务质量)。BwProvisionerSimple运行虚拟机保留尽可能多的带宽,并受主机可用带宽限制。
- CloudletScheduler 实现多种策略,用于决定虚拟机内部应用服务如何共享处理器能力。(调度策略:空间共享和时间共享策略)
- NetworkTopology 模拟网络行为(时延),保存网络拓扑信息,拓扑由BRITE拓扑生成器生成
- CloudCoordinator
- RamProvisioner 代表虚拟机分配主存的策略。主要当Ramprovisioner组件证实主机上有足够的空闲主存,虚拟机在其上执行和部署操作才是可行的。
- SanStorage 模拟了云数据中心的存储区域网,主要用于存储大量数据
- Sensor 该接口的实现必须通过实例化一个能够被云协调器使用的传感器组件,御用监控特定的性能参数(能耗、资源利用)
流程
- 初始化CloudSim
- 创建数据中心Datacenter
- 创建用户代理Broker
- 创建虚拟机VM,添加至Broker
- 创建应用Cloudlet,添加至Broker
- 开启仿真
- 结束模拟仿真
- 打印输出
相关参数
Host
参数:id、内存、带宽、储存容量、cpu。。
int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
)
);
DataCenter
参数:主机架构、操作系统、虚拟机监视器种类??、时区、cpu的使用费用、内存的使用费用、storage的使用费用、带宽的使用费用
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone = 10.0; // time zone this resource located
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this
// resource
double costPerBw = 0.0; // the cost of using bw in this resource
LinkedList<Storage> storageList = new LinkedList<Storage>(); // we are not adding SAN
// devices by now
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw); 创建数据中心特征对象来存储数据中心的参数特征
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
} 其中VmAllocationSimple表示将VM分配到已经使用Pe最少的物理机中
Virtual Machine
参数:id、mips(衡量CPU速度的一个指标,单字长定点指令平均执行速度)、镜像大小??、内存大小、带宽、CPU数、虚拟机命名
// VM description
int vmid = 0;
int mips = 1000;
long size = 10000; // image size (MB)
int ram = 512; // vm memory (MB)
long bw = 1000;
int pesNumber = 1; // number of cpus
String vmm = "Xen"; // VMM name
// create VM
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
之后// add the VM to the vmList
vmlist.add(vm);
// submit vm list to the broker
broker.submitVmList(vmlist);
Cloudlet
参数:应用编号、执行时的应用长度(MI)、要使用到的处理器数量、提交应用前的文件大小(byte)、应用执行完成后的文件大小(byte)、cpu的使用模型/策略、ram的使用模型/策略、网络带宽的使用模型/策略
// Cloudlet properties
int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet cloudlet =
new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel,
utilizationModel);
cloudlet.setUserId(brokerId);
cloudlet.setVmId(vmid);
而后// add the cloudlet to the list
cloudletList.add(cloudlet);
// submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);