本文整理汇总了Java中org.cloudbus.cloudsim.Datacenter类的典型用法代码示例。如果您正苦于以下问题:Java Datacenter类的具体用法?Java Datacenter怎么用?Java Datacenter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Datacenter类属于org.cloudbus.cloudsim包,在下文中一共展示了Datacenter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample8...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 2; // 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);
GlobalBroker globalBroker = new GlobalBroker("GlobalBroker");
// 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");
@SuppressWarnings("unused")
Datacenter datacenter1 = createDatacenter("Datacenter_1");
// Third step: Create Broker
DatacenterBroker broker = createBroker("Broker_0");
int brokerId = broker.getId();
// Fourth step: Create VMs and Cloudlets and send them to broker
vmList = createVM(brokerId, 5, 0); // creating 5 vms
cloudletList = createCloudlet(brokerId, 10, 0); // creating 10 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();
newList.addAll(globalBroker.getBroker().getCloudletReceivedList());
CloudSim.stopSimulation();
printCloudletList(newList);
Log.printLine("CloudSimExample8 finished!");
} catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
示例2: must_execute_an_experiment_with_one_datacenter
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
@Test
public void must_execute_an_experiment_with_one_datacenter()
{
// Experiment experiment = new ExperimentBuilder()
// .with(new DatacenterBuilder().with(5).hosts(
// new HostBuilder()
// .with(4, new CoreBuilder())
// .with(new RamBuilder().with().capacity(512))
// .with(new StorageBuilder().with().capacity(1000))))
// .build();
// experiment.run();
Host host = new HostBuilder().with(4).cores().with(1000).mips().using().provisioner(PeProvisionerSimple.class)
.with(512).ram().using().provisioner(RamProvisionerSimple.class)
.with(1000).storage().with(1000).bw().using().provisioner(BwProvisionerSimple.class)
.using().vm().scheduler(VmSchedulerSpaceShared.class).build();
Datacenter datacenter = new DatacenterBuilder().characteristics()
.os().linux().xen()
.costs().bw(1).cpu(1).memory(1).storage(1).timezone(1)
.storage().zero().build();
System.out.println(host);
// new ExperimentBuilder()
// .with(1)
// .dataCenter()
// .each()
// .with(5).hosts(with(4).cpu().and().with(512).ram().and().with(1).storage(with().capacity(1000)))
// .architecture(xen()).cost(cpu(2.3).and().memory(2.8).and().storage(3.2).and().bw(2.8));
}
示例3: EdgeServerManager
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
public EdgeServerManager() {
localDatacenters=new ArrayList<Datacenter>();
vmList = new ArrayList<List<EdgeVM>>();
hostIdCounter = 0;
}
示例4: getDatacenterList
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
public List<Datacenter> getDatacenterList(){
return localDatacenters;
}
示例5: terminateDatacenters
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
public void terminateDatacenters(){
for (Datacenter datacenter : localDatacenters) {
datacenter.shutdownEntity();
}
}
示例6: createDatacenter
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* Creates a datacenter
*
* @param name
* the datacenter name
* @return the datacenter
*/
public static Datacenter createDatacenter(String name) {
// Here are the steps needed to create a Datacenter:
// We need to create a list to store our machine
List<Host> hostList = createHostList(SimulationConstants.NUM_HOST);
// 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
// the cost of using processing in this resource
double cost = SimulationConstants.BROKER_VM_COST_PER_PROCESSING;
// the cost of using memory in this resource
double costPerMem = SimulationConstants.BROKER_VM_COST_PER_MEMORY;
// the cost of using storage in this resource
double costPerStorage = SimulationConstants.BROKER_VM_COST_PER_STORAGE;
// the cost of using bw in this resource
double costPerBw = 0.0;
// we are not adding SAN devices by now
LinkedList<Storage> storageList = new LinkedList<Storage>();
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(arch, os, vmm, hostList, time_zone,
cost, costPerMem, costPerStorage, costPerBw);
// We need to create a Datacenter object.
Datacenter datacenter = null;
try {
datacenter = new PSDatacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
示例7: createDatacenter
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* Creates a datacenter
*
* @return the datacenter
* @throws SimulationCreationException
*/
public static Datacenter createDatacenter(ResourceSynthesisResult resourceSynthesisResult)
throws SimulationCreationException {
// Here are the steps needed to create a Datacenter:
// We need to create a list to store our machine
List<Host> hostList = createHostList(SimulationConstants.NUM_HOST);
// 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
// the cost of using processing in this resource
double cost = SimulationConstants.BROKER_VM_COST_PER_PROCESSING;
// the cost of using memory in this resource
double costPerMem = SimulationConstants.BROKER_VM_COST_PER_MEMORY;
// the cost of using storage in this resource
double costPerStorage = SimulationConstants.BROKER_VM_COST_PER_STORAGE;
// the cost of using bw in this resource
double costPerBw = 0.0;
// we are not adding SAN devices by now
LinkedList<Storage> storageList = new LinkedList<Storage>();
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(arch, os, vmm, hostList, time_zone,
cost, costPerMem, costPerStorage, costPerBw);
String provider = resourceSynthesisResult.getProvider();
// We need to create a Datacenter object.
Datacenter datacenter = null;
try {
datacenter = new PSDatacenter(provider, characteristics, new VmAllocationPolicySimple(hostList), storageList,
DATACENTER_SCHED_INTERVAL);
} catch (Exception e) {
throw new SimulationCreationException(e.getMessage(), e);
}
return datacenter;
}
示例8: createDatacenter
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* Creates the datacenter.
*
* @param name the name
* @param datacenterClass the datacenter class
* @param hostList the host list
* @param vmAllocationPolicy the vm allocation policy
* @param simulationLength
*
* @return the power datacenter
*
* @throws Exception the exception
*/
public static Datacenter createDatacenter(
String name,
Class<? extends Datacenter> datacenterClass,
List<PowerHost> hostList,
VmAllocationPolicy vmAllocationPolicy) throws Exception {
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
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch,
os,
vmm,
hostList,
time_zone,
cost,
costPerMem,
costPerStorage,
costPerBw);
Datacenter datacenter = null;
try {
datacenter = datacenterClass.getConstructor(
String.class,
DatacenterCharacteristics.class,
VmAllocationPolicy.class,
List.class,
Double.TYPE).newInstance(
name,
characteristics,
vmAllocationPolicy,
new LinkedList<Storage>(),
Constants.SCHEDULING_INTERVAL);
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
return datacenter;
}
示例9: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* 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
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");
@SuppressWarnings("unused")
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");
}
}
示例10: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的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");
}
}
示例11: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* 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
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");
@SuppressWarnings("unused")
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");
}
}
示例12: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample8...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 2; // 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);
GlobalBroker globalBroker = new GlobalBroker("GlobalBroker");
// 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");
@SuppressWarnings("unused")
Datacenter datacenter1 = createDatacenter("Datacenter_1");
//Third step: Create Broker
DatacenterBroker broker = createBroker("Broker_0");
int brokerId = broker.getId();
//Fourth step: Create VMs and Cloudlets and send them to broker
vmList = createVM(brokerId, 5, 0); //creating 5 vms
cloudletList = createCloudlet(brokerId, 10, 0); // creating 10 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();
newList.addAll(globalBroker.getBroker().getCloudletReceivedList());
CloudSim.stopSimulation();
printCloudletList(newList);
Log.printLine("CloudSimExample8 finished!");
}
catch (Exception e)
{
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
示例13: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* 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);
//Print the debt of each user to each datacenter
datacenter0.printDebts();
datacenter1.printDebts();
Log.printLine("CloudSimExample6 finished!");
}
catch (Exception e)
{
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
示例14: main
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample8...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 2; // 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);
GlobalBroker globalBroker = new GlobalBroker("GlobalBroker");
// 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("Broker_0");
int brokerId = broker.getId();
//Fourth step: Create VMs and Cloudlets and send them to broker
vmList = createVM(brokerId, 5, 0); //creating 5 vms
cloudletList = createCloudlet(brokerId, 10, 0); // creating 10 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();
newList.addAll(globalBroker.getBroker().getCloudletReceivedList());
CloudSim.stopSimulation();
printCloudletList(newList);
//Print the debt of each user to each datacenter
datacenter0.printDebts();
datacenter1.printDebts();
Log.printLine("CloudSimExample8 finished!");
}
catch (Exception e)
{
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
示例15: initSimulation
import org.cloudbus.cloudsim.Datacenter; //导入依赖的package包/类
private static void initSimulation() {
Log.printLine("Starting CloudSim simulation Example using PSO...");
try {
// <<< [1]: Initialize the CloudSim package. It should be called
// before creating any entities. >>>
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance(); // get calendar using
// current time zone
boolean trace_flag = false; // mean trace events
CloudSim.init(num_user, calendar, trace_flag); // Initialize the
// CloudSim library
// <<< [2]: Create Datacenters >>>
Datacenter datacenter1 = createDatacenter("Datacenter_1");
// <<< [3]: Create Cloud Broker and name it Broker1 >>>
DatacenterBroker broker = createBroker(1);
int brokerId = broker.getId(); // gets the id of the created broker
// <<< [4]: Create 5 virtual machines that uses time shared
// scheduling >>>
addVMs(4, brokerId, true, 6000);//0-3
addVMs(6, brokerId, true, 12000);//4-9
// <<< [5]: submit vm list to the broker >>>
broker.submitVmList(vmlist);
// <<< [6]: Read the workload file and create Cloudlets from it
List<Cloudlet> cloudletList = createCloudLets();
// <<< [7]: assign specific VMs to run specific cloudlets
// --------------------------------------------
broker.UsePSO();
for (Cloudlet cloudlet : cloudletList) {
// set all cloudlets to be managed by one broker.
cloudlet.setUserId(brokerId);
}
// ---------------------------------------------------------------------------------------------------
// <<< [8]: submit cloudlet list to the broker >>>
broker.submitCloudletList(cloudletList);
// <<< [9]: Starts the simulation >>>
// start the simulation
CloudSim.startSimulation();
// stop the simulation
CloudSim.stopSimulation();
// <<< [10]: Print results when simulation is over
// retrieve all recieved cloudlet list
List<Cloudlet> newList = broker.getCloudletReceivedList();
// print the list
printCloudletList(newList);
// Print the debt of each user to each datacenter
// datacenter1.printDebts();
Log.printLine("CloudSimExample finished!");
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
}