/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009, The University of Melbourne, Australia
*/
//package org.cloudbus.cloudsim.examples;
//package cloudIntro;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/**
* A simple example showing how to create
* a datacenter with two hosts and run two
* cloudlets on it. The cloudlets run in
* VMs with different MIPS requirements.
* The cloudlets will take different time
* to complete the execution depending on
* the requested VM performance.
*/
public class Simulation
{
/**
* Creates main() to run this example
*/
public static void main(String[] args)
{
Log.printLine("Starting CloudSimExample3...");
try
{
int noOfTypes = 6;
// 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
// 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
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");
//Third step: Create Broker
//Fourth step: Create one virtual machine
//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
//Fifth step: Create two Cloudlets
//Cloudlet properties
int id = 0;
long length = 40000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();
int vmNumberArray[] = {1,1,1,1,1,1};
int cloudletNumberArray[] = {500,500,500,500,500,500};
ArrayList<DatacenterBroker> brokerList = new ArrayList<>();
for(int i=0;i<noOfTypes;i++) // create 6 types of vm
{
List<Cloudlet> cloudletList = new ArrayList<>();
List<Vm> vmlist = new ArrayList<>();
DatacenterBroker broker = createBroker();
brokerList.add(broker);
int brokerId = broker.getId();
//int randomNumber1 = ThreadLocalRandom.current().nextInt(1,15);
int randomNumber1 = vmNumberArray[i];
for(int j=0;j<randomNumber1;j++)
{
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
vmid++;
vmlist.add(vm);
}
//int randomNumber2 = ThreadLocalRandom.current().nextInt(20,30);
int randomNumber2 = cloudletNumberArray[i];
for(int j=0;j<randomNumber2;j++)
{
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize, outputSize, utilizationModel, utilizationModel, utilizationModel);
id++;
cloudlet.setUserId(brokerId);
cloudletList.add(cloudlet);
}
broker.submitVmList(vmlist);
broker.submitCloudletList(cloudletList);
}
long start = System.nanoTime();
CloudSim.startSimulation();
for(int i=0;i<noOfTypes;i++)
{
List<Cloudlet> cloudletList = brokerList.get(i).getCloudletReceivedList();
printCloudletList(cloudletList);
}
CloudSim.stopSimulation();
long end = System.nanoTime();
Log.printLine("CloudSim finished");
System.out.println("total time required = "+(end-start));
}
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 = 60000;
// 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 = 307230720; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000000;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
)
); // This is our first machine
//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
// 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;
}
//We strongly encourage users to develop their own broker policies, to submit vms and cloudlets according
//to the specific rules of the simulated scenario
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
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list)
{
int size = list.size();
Cloudlet cloudlet;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
"Data center ID" + indent + "VM ID" + indent + "Time" + indent + "Start Time" + indent + "Finish Time" + indent + "waiting Time");
DecimalFormat dft = new DecimalFormat("###.##");
for (int i = 0; i < size; i++)
{
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS)
{
Log.print("SUCCESS");
Log.printLine( indent + indent + cloudlet.getResourceId() + indent + indent + indent + cloudlet.getVmId() +
indent + indent + dft.format(cloudlet.getActualCPUTime()) + indent + indent + dft.format(cloudlet.getExecStartTime())+
indent + indent + dft.format(cloudlet.getFinishTime()) + dft.format(cloudlet.getWaitingTime()));
}
}
}
}
此代码由cloudsim示例3代码修改而来https://github.com/Cloudslab/cloudsim/blob/master/modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/CloudSimExample3.java.
在这里,我创建了一个数据中心,其中包含一个主机和6个数据中心代理。每个代理都有一个VM和500个Cloud dlet。
输出文件https://paste.ubuntu.com/p/ZmmK2nFmyS/
输出显示,在brocker中,每个cloudlet在某个时间启动,等待时间不显示任何表示零(0)的内容。如果VM中有一个cpu,并且没有等待时间,那么如何在VM中一次启动500个任务?
这是因为您使用了CloudletSchedulerTimeShared,而不是CloudletSchedulerSpaceShared等其他实现。在实际操作系统中,如果CPU数量低于应用程序数量(通常情况下),即使是分时调度器也会让一些应用程序等待。
CloudSim提供了一个过于简化的时间共享调度程序。有一个答案可以解释如何在这里实现这样的调度器。
如果我们有100个cloudlet和10个VM,那么如何设置cloudsim中VM的等待时间阈值,以便将该cloudlet从一个VM移动到另一个VM。
问题内容: 我正在尝试使用Allure框架为我的Selenium WebDriver 测试生成报告。我使用带有Allure版本1.3.9的框架和allure- maven-plugin 。我使用运行测试,然后使用生成报告。我在目录中看到生成的报告。当我使用Firefox 打开 index.html 页面时,它可以正常工作。但是,当在Chrome或Safari中执行相同的操作时, 我什么也看不到 。
我使用fiddler监控一个简单的html内容从一个PHP文件运行在localhost。但是每当我按f5刷新页面(浏览器)时,在fiddler中有时整个web会话的字体变成蓝色,即当它实际显示内容(html)时,相反的情况发生在web会话是灰色的时候,它不显示html内容。 注意:始终显示请求/响应标题,这仅用于内容。我还尝试了点技巧(“:80”)并从localhost切换到127.0。0.1.
人类同胞们! 我最近安装了pyGames,遵循Bryson Payne制作的令人敬畏的指南,您可以在此处找到。我按照说明中的顺序安装了以下所有依赖项和程序。 < li >已安装的XQuartz < li >已经安装了Homebrew(这是第二步)。 < li >安装了一个来自homebrew的python 3版本,专门用于py game < li >对终端执行了以下命令:brew install
我正在使用Android Espresso Web测试Android应用程序中的Web视图。它需要一些时间来完成与加载网站。在对元素执行单击操作之前,我需要等待它显示出来。我能用什么API吗?我不想使用sleep()方法。
Cloudsim中的分时是如何工作的,没有代表时间片或量子的变量,那么循环的概念在Cloudsim中是如何验证的呢? 如果我们有50个Cloudlet,10个VM