学习笔记
分享学习经验,记录生活点滴

CloudSimExample的不同之处

Example1:

通过一个简单的例子展示:如何创建只有一台主机的数据中心,并在其上面运行一个云任务
虚拟机负责云任务的调度,
云任务在虚拟机上面运行,
代理负责虚拟机到数据中心的映射,
代理管理虚拟机和云任务,
数据中心由一些列的主机组成。

Example2:

一个简单的例子向大家展示:如何创建一个只含有一台主机的数据中心,并在其上面运行两个云任务。
这两个云任务运行在具有相同的MIPS的虚拟机上面,并且它们所需的运行时间也是相同的。

Example3:

一个简单示例,说明如何使用两个主机创建数据中心并在其上运行两个云任务。 云任务在具有不同MIPS要求的VM中运行。
根据请求的VM性能,云任务将花费不同的时间来完成执行。

Example4:

* 一个简单的示例,演示如何创建两个数据中心,每个数据中心一个主机,并在其上运行两个cloudlet。

Example5:

*一个简单的示例,演示如何创建两个数据中心,每个数据中心一个主机,并在其上运行两个用户的云任务。

Example6:

* 通过一个简单的例子向大家展示如何创建可扩展的仿真。

Example7:

* 通过一个简单的例子展示如何暂停和重启仿真,如何动态的创建仿真实体(在这个例子中以DatacenterBroker为例)。

Example8:

*示例演示如何使用globar管理器实体(GlobalBroker)在运行时创建模拟实体(在此示例中为DatacenterBroker)。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example1与Example2代码的不同之处:

(1)创建虚拟机

//Example1
// create VM
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared()); 
//add the VMs to the vmList
vmlist.add(vm);
//submit vm list to the broker
broker.submitVmList(vmlist);
//Example2
//create two VMs 
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
vmid++;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmList
vmlist.add(vm1);
vmlist.add(vm2);
//submit vm list to the broker
broker.submitVmList(vmlist);

(2)创建云任务

//Example1
// Fifth step: Create one Cloudlet 创建云任务
cloudletList = new ArrayList<Cloudlet>();
// 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); //将云任务提交给代理
//Example2
//Fifth step: Create two Cloudlets
cloudletList = new ArrayList<Cloudlet>();

//Cloudlet properties
int id = 0;
pesNumber=1;
long length = 250000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();//设置资源使用率模型

Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber, fileSize, outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);

id++;
Cloudlet cloudlet2 = new Cloudlet(id, length, pesNumber, fileSize, outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId);

//add the cloudlets to the list
cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);

//submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);

// bind the cloudlets to the vms. This way, the broker
// will submit the bound cloudlets only to the specific VM 
// 绑定云任务到虚拟机,这样,broker将相应的云任务只会提交给相应制定的虚拟机
broker.bindCloudletToVm(cloudlet1.getCloudletId(),vm1.getId());
broker.bindCloudletToVm(cloudlet2.getCloudletId(),vm2.getId());

Example3与Example2代码的不同之处:

(1)Example3创建两个不同MIPS要求的VM

Example3与Example2代码不同在于vm2里面参数为mips*2

Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());

//the second VM will have twice the priority of VM1 and so will receive twice CPU time
//注意第二台虚拟机的mips是第一台虚拟机的mips的两倍
vmid++;
Vm vm2 = new Vm(vmid, brokerId, mips * 2, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());

//add the VMs to the vmList
vmlist.add(vm1);
vmlist.add(vm2);

//submit vm list to the broker
broker.submitVmList(vmlist);

(2)Example3创建两个Host

List<Host> hostList = new ArrayList<Host>();

// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
List<Pe> peList = new ArrayList<Pe>();

int mips = 1000;

// 3. Create PEs and add these into a list.
peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id and MIPS Rating

//4. Create Hosts with its id and list of PEs and add them to the list of machines
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)
)
); // This is our first machine

*Example2创建一个主机,到此结束。Example3创建两个主机,下面接着创建另一个*

//create another machine in the Data center
List<Pe> peList2 = new ArrayList<Pe>();

peList2.add(new Pe(0, new PeProvisionerSimple(mips)));

hostId++;

hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList2,
new VmSchedulerTimeShared(peList2)
)
); // This is our second machine
赞(4) 打赏
未经允许不得转载:ABCLearning » CloudSimExample的不同之处
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

阿里云限时红包 助力一步上云

了解详情领取红包

觉得文章有用就打赏一下文章作者

微信扫一扫打赏