CloudSim 示例:模拟云环境的实践探索
1. CloudSim Example 3 概述
CloudSim Example 3 是一个基础的云模拟示例,展示了云环境中数据中心、代理、虚拟机和云任务的基本交互流程。
以下是该示例的主要执行步骤:
1.
初始化
:启动 CloudSim 版本 3.0,数据中心和代理开始启动。
2.
资源分配
:代理接收云资源列表,尝试在数据中心创建虚拟机。
3.
云任务调度
:虚拟机创建成功后,代理将云任务发送到相应的虚拟机执行。
4.
任务完成
:云任务执行完成后,代理销毁虚拟机并关闭。
5.
模拟结束
:所有事件处理完毕,数据中心和代理关闭,模拟完成。
以下是该示例的输出日志:
Output: CloudSimExample 3
Starting CloudSimExample3...
Initialising...
Starting CloudSim version 3.0
Datacenter 0 is starting...
Broker is starting...
Entities started.
0.0: Broker: Cloud Resource List received with 1 resource(s)
0.0: Broker: Trying to Create VM #0 in Datacenter 0
0.0: Broker: Trying to Create VM #1 in Datacenter 0
0.1: Broker: VM #0 has been created in Datacenter #2, Host #0
0.1: Broker: VM #1 has been created in Datacenter #2, Host #1
0.1: Broker: Sending Cloudlet 0 to VM #0
0.1: Broker: Sending Cloudlet 1 to VM #1
80.1: Broker: Cloudlet 1 received
160.1: Broker: Cloudlet 0 received
160.1: Broker: All Cloudlets executed. Finishing...
160.1: Broker: Destroying VM #0
160.1: Broker: Destroying VM #1
Broker is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter 0 is shutting down...
Broker is shutting down...
Simulation completed.
该示例的执行结果可以用表格展示:
| Cloudlet ID | STATUS | Data Center ID | VM ID | Time | Start Time | Finish Time |
| — | — | — | — | — | — | — |
| 1 | SUCCESS | 2 | 1 | 80 | 0.1 | 80.1 |
| 0 | SUCCESS | 2 | 0 | 160 | 0.1 | 160.1 |
2. CloudSim Example 4:创建双数据中心并运行云任务
CloudSim Example 4 展示了如何创建两个数据中心,每个数据中心包含一个主机,并在这些主机上运行两个云任务。
以下是创建两个数据中心并运行两个云任务的算法步骤:
1.
初始化 CloudSim 包
:在创建任何实体之前调用。
2.
创建数据中心
:创建两个数据中心。
3.
创建代理
:创建一个代理来管理虚拟机和云任务。
4.
创建虚拟机
:创建两个虚拟机并添加到虚拟机列表。
5.
提交虚拟机列表
:将虚拟机列表提交给代理。
6.
创建云任务
:创建两个云任务并添加到云任务列表。
7.
提交云任务列表
:将云任务列表提交给代理。
8.
绑定云任务和虚拟机
:将云任务绑定到特定的虚拟机。
9.
启动模拟
:开始模拟云环境。
10.
输出结果
:模拟结束后打印结果。
以下是该示例的源代码:
public class CloudSimExample4 {
/** The Cloudlet list. */
private static List<Cloudlet> CloudletList;
/** The vmlist. */
private static List<Vm> vmlist;
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample4...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 1; // number of Cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
//Datacenters are the resource providers in CloudSim. We need at list one of
//them to run a CloudSim simulation
Datacenter datacenter0 = createDatacenter("Datacenter 0");
Datacenter datacenter1 = createDatacenter("Datacenter 1");
//Third step: Create Broker
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
//Fourth step: Create one virtual machine
vmlist = new ArrayList<Vm>();
//VM description
int vmid = 0;
int mips = 250;
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 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);
//Fifth step: Create two Cloudlets
CloudletList = new ArrayList<Cloudlet>();
//Cloudlet properties
int id = 0;
long length = 40000;
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.bindCloudletToVm(Cloudlet1.getCloudletId(), vm1.getId());
broker.bindCloudletToVm(Cloudlet2.getCloudletId(), vm2.getId());
// Sixth step: Starts the simulation
CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
Log.printLine("CloudSimExample4 finished!");
} catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
private static Datacenter createDatacenter(String name) {
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store
// our machine
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 Host 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;
//in this example, the VMAllocatonPolicy in use is SpaceShared. It means
//that only one VM
//is allowed to run on each Pe. As each Host has only one Pe, only one VM
//can run on each Host.
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerSpaceShared(peList)
)
); // This is our first machine
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
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);
// 6. Finally, we need to create a PowerDatacenter object.
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
private static DatacenterBroker createBroker() {
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
/** Prints the Cloudlet objects */
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet Cloudlet;
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + "STATUS" + "Data center ID" + "VM ID"
+ "Time" + "Start Time" + "Finish Time");
for (int i = 0; i < size; i++) {
Cloudlet = list.get(i);
Log.print(Cloudlet.getCloudletId());
if (Cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
}
Log.printLine(Cloudlet.getResourceId() + Cloudlet.getVmId() + Cloudlet.getActualCPUTime() + Cloudlet.getExecStartTime() + Cloudlet.getFinishTime());
}
}
}
该示例的输出日志如下:
Output: CloudSim Example4
Starting CloudSimExample4...
Initialising...
Starting CloudSim version 3.0
Datacenter 0 is starting...
Datacenter 1 is starting...
Broker is starting...
Entities started.
0.0: Broker: Cloud Resource List received with 2 resource(s)
0.0: Broker: Trying to Create VM #0 in Datacenter 0
0.0: Broker: Trying to Create VM #1 in Datacenter 0
[VmScheduler.vmCreate] Allocation of VM #1 to Host #0 failed by MIPS
0.1: Broker: VM #0 has been created in Datacenter #2, Host #0
0.1: Broker: Creation of VM #1 failed in Datacenter #2
0.1: Broker: Trying to Create VM #1 in Datacenter 1
0.2: Broker: VM #1 has been created in Datacenter #3, Host #0
0.2: Broker: Sending Cloudlet 0 to VM #0
0.2: Broker: Sending Cloudlet 1 to VM #1
160.2: Broker: Cloudlet 0 received
160.2: Broker: Cloudlet 1 received
160.2: Broker: All Cloudlets executed. Finishing...
160.2: Broker: Destroying VM #0
160.2: Broker: Destroying VM #1
Broker is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter 0 is shutting down...
Datacenter 1 is shutting down...
Broker is shutting down...
Simulation completed.
执行结果表格如下:
| Cloudlet ID | STATUS | Data Center ID | VM ID | Time | Start Time | Finish Time |
| — | — | — | — | — | — | — |
| 0 | SUCCESS | 2 | 0 | 160 | 0.2 | 160.2 |
| 1 | SUCCESS | 3 | 1 | 160 | 0.2 | 160.2 |
3. CloudSim Example 5:容器初始放置问题探索
CloudSim Example 5 主要探索了容器初始放置的问题,涉及虚拟机分配策略、容器选择策略等多个方面。
以下是该示例的主要步骤:
1.
获取工作负载路径
:获取 planet lab 工作负载的路径。
2.
创建输出文件夹
:创建用于存储日志的输出文件夹。
3.
定义策略
:定义虚拟机分配策略、容器选择策略、容器分配策略、主机选择策略和虚拟机选择策略。
4.
设置容器超订因子
:设置容器超订因子以实现资源超订。
5.
运行模拟
:重复运行模拟多次。
以下是该示例的源代码:
package org.cloudbus.cloudsim.examples.container;
public class ContainerInitialPlacementTest {
public static void main(String[] args) throws IOException {
/**
* The experiments can be repeated for (repeat runtime +1) times.
* Please set these values as the arguments of the main function or set them
* bellow:
*/
int runTime = Integer.parseInt(args[0]);
int repeat = Integer.parseInt(args[1]);
for (int i = runTime; i < repeat; ++i) {
boolean enableOutput = true;
boolean outputToFile = true;
/**
* Getting the path of the planet lab workload that is included in the cloudSim
* Package
*/
String inputFolder = ContainerOverbooking.class.getClassLoader().getResource("workload/planetlab").getPath();
/**
* The output folder for the logs. The log files would be located in this folder.
*/
String outputFolder = " /Results";
/**
* The allocation policy for VMs.
*/
String vmAllocationPolicy = "MSThreshold-Under 0.80 0.70";
/**
* The selection policy for containers where a container migration is triggered.
*/
String containerSelectionPolicy = "MaxUsage";
/**
* The allocation policy used for allocating containers to VMs.
*/
String containerAllocationPolicy = "MostFull";
/**
* The host selection policy determines which hosts should be selected as the
* migration destination.
*/
String hostSelectionPolicy = "FirstFit";
/**
* The VM Selection Policy is used for selecting VMs to migrate when a host
* status is determined as
* “Overloaded”
*/
String vmSelectionPolicy = "VmMaxC";
/**
* The container overbooking factor is used for overbooking resources of the
* VM. In this specific case
* the overbooking is performed on CPU only.
*/
int OverBookingFactor = 80;
new RunnerInitiator(
enableOutput,
outputToFile,
inputFolder,
outputFolder,
vmAllocationPolicy,
containerAllocationPolicy,
vmSelectionPolicy,
containerSelectionPolicy,
hostSelectionPolicy,
OverBookingFactor, Integer.toString(i), outputFolder);
}
}
}
该示例的输出日志如下:
OUTPUT: CloudSim Example5
Starting CloudSimExample5...
Initialising...
Starting CloudSim version 3.0
Datacenter 0 is starting...
Datacenter 1 is starting...
Broker1 is starting...
Broker2 is starting...
Entities started.
0.0: Broker1: Cloud Resource List received with 2 resource(s)
0.0: Broker2: Cloud Resource List received with 2 resource(s)
0.0: Broker1: Trying to Create VM #0 in Datacenter 0
0.0: Broker2: Trying to Create VM #0 in Datacenter 0
[VmScheduler.vmCreate] Allocation of VM #0 to Host #0 failed by MIPS
0.1: Broker1: VM #0 has been created in Datacenter #2, Host #0
0.1: Broker1: Sending Cloudlet 0 to VM #0
0.1: Broker2: Creation of VM #0 failed in Datacenter #2
0.1: Broker2: Trying to Create VM #0 in Datacenter 1
0.2: Broker2: VM #0 has been created in Datacenter #3, Host #0
0.2: Broker2: Sending Cloudlet 0 to VM #0
160.1: Broker1: Cloudlet 0 received
160.1: Broker1: All Cloudlets executed. Finishing...
160.1: Broker1: Destroying VM #0
Broker1 is shutting down...
160.2: Broker2: Cloudlet 0 received
160.2: Broker2: All Cloudlets executed. Finishing...
160.2: Broker2: Destroying VM #0
Broker2 is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter 0 is shutting down...
Datacenter 1 is shutting down...
Broker1 is shutting down...
Broker2 is shutting down...
Simulation completed.
执行结果表格如下:
| Cloudlet ID | STATUS | Data Center ID | VM ID | Time | Start Time | Finish Time |
| — | — | — | — | — | — | — |
| 0 | SUCCESS | 2 | 0 | 160 | 0.1 | 160.1 |
| 0 | SUCCESS | 3 | 0 | 160 | 0.2 | 160.2 |
通过以上三个示例,我们可以看到 CloudSim 在模拟云环境方面的强大功能。从简单的资源分配到复杂的容器放置问题,CloudSim 提供了丰富的工具和接口,帮助我们深入理解和研究云环境的运行机制。在后续的示例中,我们将继续探索如何创建可扩展的模拟以及更多高级功能。
4. CloudSim Example 6:创建可扩展的模拟
CloudSim Example 6 展示了如何创建可扩展的云模拟,该示例通过创建多个虚拟机和云任务,模拟大规模的云环境。
以下是创建可扩展模拟的算法步骤:
1.
创建虚拟机列表
:创建一个容器来存储虚拟机,并设置虚拟机的参数。
2.
创建云任务列表
:创建一个容器来存储云任务,并设置云任务的参数。
3.
初始化 CloudSim 包
:在创建任何实体之前调用,初始化 CloudSim 库。
4.
创建数据中心
:创建两个数据中心。
5.
创建代理
:创建一个代理来管理虚拟机和云任务。
6.
提交虚拟机和云任务列表
:将虚拟机和云任务列表提交给代理。
7.
启动模拟
:开始模拟云环境。
8.
输出结果
:模拟结束后打印结果。
以下是该示例的源代码:
public class CloudSimExample6 {
/** The Cloudlet list. */
private static List<Cloudlet> CloudletList;
/** The vmlist. */
private static List<Vm> vmlist;
private static List<Vm> createVM(int userId, int vms) {
//Creates a container to store VMs. This list is passed to the broker later
LinkedList<Vm> list = new LinkedList<Vm>();
//VM Parameters
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int mips = 1000;
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name
//create VMs
Vm[] vm = new Vm[vms];
for(int i = 0; i < vms; i++) {
vm[i] = new Vm(i, userId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//for creating a VM with a space shared scheduling policy for Cloudlets:
//vm[i] = Vm(i, userId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerSpaceShared());
list.add(vm[i]);
}
return list;
}
private static List<Cloudlet> createCloudlet(int userId, int Cloudlets) {
// Creates a container to store Cloudlets
LinkedList<Cloudlet> list = new LinkedList<Cloudlet>();
//Cloudlet parameters
long length = 1000;
long fileSize = 300;
long outputSize = 300;
int pesNumber = 1;
UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet[] Cloudlet = new Cloudlet[Cloudlets];
for(int i = 0; i < Cloudlets; i++) {
Cloudlet[i] = new Cloudlet(i, length, pesNumber, fileSize, outputSize, utilizationModel, utilizationModel,
utilizationModel);
// setting the owner of these Cloudlets
Cloudlet[i].setUserId(userId);
list.add(Cloudlet[i]);
}
return list;
}
/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample6...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 1; // number of grid users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
//Datacenters are the resource providers in CloudSim. We need at list one of
//them to run a CloudSim simulation
Datacenter datacenter0 = createDatacenter("Datacenter 0");
Datacenter datacenter1 = createDatacenter("Datacenter 1");
//Third step: Create Broker
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
//Fourth step: Create VMs and Cloudlets and send them to broker
vmlist = createVM(brokerId, 20); //creating 20 vms
CloudletList = createCloudlet(brokerId, 40); // creating 40 Cloudlets
broker.submitVmList(vmlist);
broker.submitCloudletList(CloudletList);
// Fifth step: Starts the simulation
CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
Log.printLine("CloudSimExample6 finished!");
} catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
private static Datacenter createDatacenter(String name) {
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store one or more
// Machines
List<Host> hostList = new ArrayList<Host>();
// 2. A Machine contains one or more PEs or CPUs/Cores. Therefore, should
// create a list to store these PEs before creating
// a Machine.
List<Pe> peList1 = new ArrayList<Pe>();
int mips = 1000;
// 3. Create PEs and add these into the list.
//for a quad-core machine, a list of 4 PEs is required:
peList1.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id and MIPS Rating
peList1.add(new Pe(1, new PeProvisionerSimple(mips)));
peList1.add(new Pe(2, new PeProvisionerSimple(mips)));
peList1.add(new Pe(3, new PeProvisionerSimple(mips)));
//Another list, for a dual-core machine
List<Pe> peList2 = new ArrayList<Pe>();
peList2.add(new Pe(0, new PeProvisionerSimple(mips)));
peList2.add(new Pe(1, new PeProvisionerSimple(mips)));
//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,
peList1,
new VmSchedulerTimeShared(peList1)
)
); // This is our first machine
hostId++;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList2,
new VmSchedulerTimeShared(peList2)
)
); // Second machine
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
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.1; // the cost of using storage in this resource
double costPerBw = 0.1; // 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);
// 6. Finally, we need to create a PowerDatacenter object.
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
private static DatacenterBroker createBroker() {
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
/* Prints the Cloudlet objects */
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet Cloudlet;
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + "STATUS" + "Data center ID" + "VM ID"
+ "Time" + "Start Time" + "Finish Time");
for (int i = 0; i < size; i++) {
Cloudlet = list.get(i);
Log.print(Cloudlet.getCloudletId());
if (Cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
}
Log.printLine(Cloudlet.getResourceId() + Cloudlet.getVmId() + (Cloudlet.getActualCPUTime() +
Cloudlet.getExecStartTime() + Cloudlet.getFinishTime()));
}
}
}
该示例的输出日志如下:
Output:CloudSim Example6 Starting CloudSimExample6...
Initialising...
Starting CloudSim version 3.0
Datacenter 0 is starting...
Datacenter 1 is starting...
Broker is starting...
Entities started.
0.0: Broker: Cloud Resource List received with 2 resource(s)
. . . 0.0: Broker: Trying to Create VM #3 in Datacenter 0
. . . . . . 0.0: Broker: Trying to Create VM #17 in Datacenter 0
0.0: Broker: Trying to Create VM #18 in Datacenter 0
0.0: Broker: Trying to Create VM #19 in Datacenter 0
[VmScheduler.vmCreate] Allocation of VM #6 to Host #0 failed by RAM
. . . . . . [VmScheduler.vmCreate] Allocation of VM #18 to Host #1 failed by MIPS
[VmScheduler.vmCreate] Allocation of VM #19 to Host #0 failed by RAM
[VmScheduler.vmCreate] Allocation of VM #19 to Host #1 failed by MIPS
0.1: Broker: VM #0 has been created in Datacenter #2, Host #0
. . . 0.1: Broker: VM #5 has been created in Datacenter #2, Host #1
0.1: Broker: Creation of VM #6 failed in Datacenter #2
. . . 0.1: Broker: Creation of VM #19 failed in Datacenter #2
. . . 0.1: Broker: Trying to Create VM #13 in Datacenter 1
0.1: Broker: Trying to Create VM #14 in Datacenter 1
–
–
–
[VmScheduler.vmCreate] Allocation of VM #12 to Host #0 failed by RAM
. . . . . .
Broker is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter 0 is shutting down...
Datacenter 1 is shutting down...
Broker is shutting down...
Simulation completed.
该示例的执行流程可以用 mermaid 流程图表示:
graph TD;
A[初始化 CloudSim] --> B[创建数据中心];
B --> C[创建代理];
C --> D[创建虚拟机列表];
D --> E[创建云任务列表];
E --> F[提交虚拟机和云任务列表给代理];
F --> G[启动模拟];
G --> H[输出结果];
总结
通过以上四个 CloudSim 示例,我们对云模拟有了更深入的了解。从基础的资源分配模拟到复杂的容器初始放置和可扩展模拟,CloudSim 提供了丰富的功能和接口,帮助我们模拟不同场景下的云环境。
在实际应用中,我们可以根据需求选择合适的示例进行参考,例如在研究云资源分配策略时,可以参考 CloudSim Example 3 和 4;在探索容器放置问题时,可以参考 CloudSim Example 5;在进行大规模云模拟时,可以参考 CloudSim Example 6。
同时,我们也可以根据这些示例的代码进行扩展和修改,以满足特定的研究需求。例如,可以调整虚拟机和云任务的参数,改变数据中心的配置,或者实现自定义的调度策略等。
希望这些示例能为大家在云模拟领域的研究和实践提供有价值的参考。
超级会员免费看
739

被折叠的 条评论
为什么被折叠?



