我使用loop创建10 vm。每个Vm使用相同数量的MIPS,因为所有Vms的参数都相同。我可以用不同的mips创建不同的vms吗?
//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
CondorVM[] vm = new CondorVM[vms];
for (int i = 0; i < vms; i++) {
double ratio = 1.0;
vm[i] = new CondorVM(i, userId, mips * ratio, pesNumber, ram, bw, size, vmm, new CloudletSchedulerSpaceShared());
list.add(vm[i]);
}
return list;
}
初始化vmNum的主方法中的等于10.
答案 0 :(得分:0)
简单就是这样。创建一个mips数组并通过循环将其传递给vm构造函数。
在你的例子中:
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int[] mips= {1000,200,3000,.....,500}; //Here's the array
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name
//create VMs
CondorVM[] vm = new CondorVM[vms];
for (int i = 0; i < vms; i++) {
double ratio = 1.0;
vm[i] = new CondorVM(i, userId, mips[i] * ratio, pesNumber, ram, bw, size, vmm, new CloudletSchedulerSpaceShared());
list.add(vm[i]);
}
return list;
}
希望它能帮到你!!