Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updates UtilizationModelPlanetLab docs and performs small refactoring Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
- Loading branch information
1 parent
bdc0a59
commit fcf3796
Showing
5 changed files
with
245 additions
and
29 deletions.
There are no files selected for viewing
188 changes: 188 additions & 0 deletions
188
cloudsim-plus-examples/src/main/java/org/cloudsimplus/examples/PlanetLabExample1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
/* | ||
* CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for | ||
* Modeling and Simulation of Cloud Computing Infrastructures and Services. | ||
* http://cloudsimplus.org | ||
* | ||
* Copyright (C) 2015-2018 Universidade da Beira Interior (UBI, Portugal) and | ||
* the Instituto Federal de Educa莽茫o Ci锚ncia e Tecnologia do Tocantins (IFTO, Brazil). | ||
* | ||
* This file is part of CloudSim Plus. | ||
* | ||
* CloudSim Plus is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* CloudSim Plus is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with CloudSim Plus. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.cloudsimplus.examples; | ||
|
||
import org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicySimple; | ||
import org.cloudbus.cloudsim.brokers.DatacenterBroker; | ||
import org.cloudbus.cloudsim.brokers.DatacenterBrokerSimple; | ||
import org.cloudbus.cloudsim.cloudlets.Cloudlet; | ||
import org.cloudbus.cloudsim.cloudlets.CloudletSimple; | ||
import org.cloudbus.cloudsim.core.CloudSim; | ||
import org.cloudbus.cloudsim.datacenters.Datacenter; | ||
import org.cloudbus.cloudsim.datacenters.DatacenterSimple; | ||
import org.cloudbus.cloudsim.hosts.Host; | ||
import org.cloudbus.cloudsim.hosts.HostSimple; | ||
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple; | ||
import org.cloudbus.cloudsim.provisioners.ResourceProvisionerSimple; | ||
import org.cloudbus.cloudsim.resources.Pe; | ||
import org.cloudbus.cloudsim.resources.PeSimple; | ||
import org.cloudbus.cloudsim.schedulers.cloudlet.CloudletSchedulerTimeShared; | ||
import org.cloudbus.cloudsim.schedulers.vm.VmSchedulerTimeShared; | ||
import org.cloudbus.cloudsim.utilizationmodels.UtilizationModel; | ||
import org.cloudbus.cloudsim.utilizationmodels.UtilizationModelDynamic; | ||
import org.cloudbus.cloudsim.utilizationmodels.UtilizationModelPlanetLab; | ||
import org.cloudbus.cloudsim.vms.Vm; | ||
import org.cloudbus.cloudsim.vms.VmSimple; | ||
import org.cloudsimplus.builders.tables.CloudletsTableBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
/** | ||
* An example showing how to use the {@link UtilizationModelPlanetLab} class | ||
* to define Cloudlets' CPU utilization based on <a href="https://www.planet-lab.org">PlanetLab's</a> trace files. | ||
* Check the {@link #createCloudlets()} method. | ||
* | ||
* @author Manoel Campos da Silva Filho | ||
* @since CloudSim Plus 4.0.0 | ||
*/ | ||
public class PlanetLabExample1 { | ||
private static final int HOSTS = 3; | ||
private static final int HOST_PES = 10; | ||
|
||
private static final int VMS = 4; | ||
private static final int VM_PES = 4; | ||
private static final int VM_MIPS = 1000; | ||
|
||
private static final int CLOUDLETS = 4; | ||
private static final int CLOUDLET_PES = 2; | ||
private static final int CLOUDLET_LENGTH = 100000000; | ||
|
||
private static final String TRACE_FILE = "workload/planetlab/20110303/75-130-96-12_static_oxfr_ma_charter_com_irisaple_wup"; | ||
|
||
/** | ||
* The time interval in which precise values can be got from | ||
* the PlanetLab {@link #TRACE_FILE}. | ||
* Such a value must be also defined as the Datacenter | ||
* scheduling interval to ensure that Cloudlets' processing | ||
* is updated with the values read from the trace file | ||
* at the given interval. | ||
* | ||
* @see UtilizationModelPlanetLab#getSchedulingInterval() | ||
*/ | ||
private static final int SCHEDULING_INTERVAL = 300; | ||
|
||
private final CloudSim simulation; | ||
private DatacenterBroker broker0; | ||
private List<Vm> vmList; | ||
private List<Cloudlet> cloudletList; | ||
private Datacenter datacenter0; | ||
|
||
public static void main(String[] args) { | ||
new PlanetLabExample1(); | ||
} | ||
|
||
public PlanetLabExample1() { | ||
/*Enables just some level of log messages. | ||
Make sure to import org.cloudsimplus.util.Log;*/ | ||
//Log.setLevel(ch.qos.logback.classic.Level.WARN); | ||
|
||
simulation = new CloudSim(); | ||
datacenter0 = createDatacenter(); | ||
|
||
//Creates a broker that is a software acting on behalf a cloud customer to manage his/her VMs and Cloudlets | ||
broker0 = new DatacenterBrokerSimple(simulation); | ||
|
||
vmList = createVms(); | ||
cloudletList = createCloudlets(); | ||
broker0.submitVmList(vmList); | ||
broker0.submitCloudletList(cloudletList); | ||
|
||
simulation.start(); | ||
|
||
final List<Cloudlet> finishedCloudlets = broker0.getCloudletFinishedList(); | ||
new CloudletsTableBuilder(finishedCloudlets).build(); | ||
} | ||
|
||
/** | ||
* Creates a Datacenter and its Hosts. | ||
*/ | ||
private Datacenter createDatacenter() { | ||
final List<Host> hostList = new ArrayList<>(HOSTS); | ||
for(int i = 0; i < HOSTS; i++) { | ||
Host host = createHost(); | ||
hostList.add(host); | ||
} | ||
|
||
final DatacenterSimple dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple()); | ||
dc.setSchedulingInterval(SCHEDULING_INTERVAL); | ||
return dc; | ||
} | ||
|
||
private Host createHost() { | ||
final List<Pe> peList = new ArrayList<>(HOST_PES); | ||
//List of Host's CPUs (Processing Elements, PEs) | ||
IntStream.range(0, HOST_PES).forEach(i -> peList.add(new PeSimple(1000, new PeProvisionerSimple()))); | ||
|
||
final long ram = 2048; //in Megabytes | ||
final long bw = 10000; //in Megabits/s | ||
final long storage = 1000000; //in Megabytes | ||
Host host = new HostSimple(ram, bw, storage, peList); | ||
host | ||
.setRamProvisioner(new ResourceProvisionerSimple()) | ||
.setBwProvisioner(new ResourceProvisionerSimple()) | ||
.setVmScheduler(new VmSchedulerTimeShared()); | ||
return host; | ||
} | ||
|
||
/** | ||
* Creates a list of VMs. | ||
*/ | ||
private List<Vm> createVms() { | ||
final List<Vm> list = new ArrayList<>(VMS); | ||
for (int i = 0; i < VMS; i++) { | ||
Vm vm = | ||
new VmSimple(i, VM_MIPS, VM_PES) | ||
.setRam(512).setBw(1000).setSize(10000) | ||
.setCloudletScheduler(new CloudletSchedulerTimeShared()); | ||
|
||
list.add(vm); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
/** | ||
* Creates a list of Cloudlets setting their CPU UtilizationModel as | ||
* a {@link UtilizationModelPlanetLab} that read CPU utilization from | ||
* a PlanetLab trace file. | ||
*/ | ||
private List<Cloudlet> createCloudlets() { | ||
final List<Cloudlet> list = new ArrayList<>(CLOUDLETS); | ||
final UtilizationModel utilizationCpu = UtilizationModelPlanetLab.getInstance(TRACE_FILE, SCHEDULING_INTERVAL); | ||
for (int i = 0; i < CLOUDLETS; i++) { | ||
Cloudlet cloudlet = | ||
new CloudletSimple(i, CLOUDLET_LENGTH, CLOUDLET_PES) | ||
.setFileSize(1024) | ||
.setOutputSize(1024) | ||
.setUtilizationModelCpu(utilizationCpu) | ||
.setUtilizationModelBw(new UtilizationModelDynamic(0.2)) | ||
.setUtilizationModelRam(new UtilizationModelDynamic(0.4)); | ||
list.add(cloudlet); | ||
} | ||
|
||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
cloudsim-plus/src/test/resources/sample-planetlab-trace.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#A sample and synthetic PlanetLab file created for test purposes | ||
10 | ||
20 | ||
30 | ||
40 | ||
50 | ||
60 | ||
70 | ||
80 | ||
90 | ||
100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters