本文整理汇总了Java中org.cloudbus.cloudsim.Cloudlet.setUserId方法的典型用法代码示例。如果您正苦于以下问题:Java Cloudlet.setUserId方法的具体用法?Java Cloudlet.setUserId怎么用?Java Cloudlet.setUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cloudbus.cloudsim.Cloudlet
的用法示例。
在下文中一共展示了Cloudlet.setUserId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateCloudlet
import org.cloudbus.cloudsim.Cloudlet; //导入方法依赖的package包/类
private Cloudlet generateCloudlet(int vmId, int length) {
int peNum=1;
long fileSize = 300;
long outputSize = 300;
Cloudlet cloudlet= new Cloudlet(cloudletId++, length, peNum, fileSize, outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet.setUserId(userId);
cloudlet.setVmId(vmId);
return cloudlet;
}
示例2: main
import org.cloudbus.cloudsim.Cloudlet; //导入方法依赖的package包/类
/**
* Creates main() to run this example.
*
* @param args the args
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample1...");
try {
// 1,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的一些属性的初始化 Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// 2,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");
// 3,Third step: Create Broker 创建云计算服务平台代理
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
// 4,Fourth step: Create one virtual machine
vmlist = new ArrayList<Vm>(); //a,创建虚拟机列表
// VM description 虚拟机的参数
int vmid = 0; //虚拟机id
int mips = 1000; //每秒百万条指令
long size = 10000; // image size (MB)镜像大小 size amount of storage
int ram = 512; // vm memory (MB)内存大小
long bw = 1000; //带宽
int pesNumber = 1; // number of cpus cpu数
String vmm = "Xen"; // VMM name 虚拟机名字 vmm virtual machine monitor
// create VM b,创建一个虚拟机
// new CloudletSchedulerTimeShared()设置虚拟机的调度策略
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
// add the VM to the vmList c,把虚拟机假如虚拟机列表
vmlist.add(vm);
// submit vm list to the broker d,将虚拟机列表提交到数据中心代理中
broker.submitVmList(vmlist);
// 5,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); //将云任务提交给代理
// 6,Sixth step: Starts the simulation
CloudSim.startSimulation(); //开始模拟
CloudSim.stopSimulation(); //结束模拟
//7,Final step: Print results when simulation is over 输出结果
List<Cloudlet> newList = broker.getCloudletReceivedList();
printCloudletList(newList);
Log.printLine("CloudSimExample1 finished!");
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
}