Commit cbdf2342 authored by Kaio Oliveira's avatar Kaio Oliveira
Browse files

Update VmAllocationPolicyMigrationSla example

parent 970ef331
...@@ -16,11 +16,13 @@ import org.cloudbus.cloudsim.hosts.Host; ...@@ -16,11 +16,13 @@ import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.hosts.HostSimple; import org.cloudbus.cloudsim.hosts.HostSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple; import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.ResourceProvisioner; import org.cloudbus.cloudsim.provisioners.ResourceProvisioner;
import org.cloudbus.cloudsim.provisioners.ResourceProvisionerShared;
import org.cloudbus.cloudsim.provisioners.ResourceProvisionerSimple; import org.cloudbus.cloudsim.provisioners.ResourceProvisionerSimple;
import org.cloudbus.cloudsim.resources.Pe; import org.cloudbus.cloudsim.resources.Pe;
import org.cloudbus.cloudsim.resources.PeSimple; import org.cloudbus.cloudsim.resources.PeSimple;
import org.cloudbus.cloudsim.schedulers.cloudlet.CloudletSchedulerTimeShared; import org.cloudbus.cloudsim.schedulers.cloudlet.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.schedulers.vm.VmScheduler; import org.cloudbus.cloudsim.schedulers.vm.VmScheduler;
import org.cloudbus.cloudsim.schedulers.vm.VmSchedulerSpaceShared;
import org.cloudbus.cloudsim.schedulers.vm.VmSchedulerTimeShared; import org.cloudbus.cloudsim.schedulers.vm.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.utilizationmodels.UtilizationModel; import org.cloudbus.cloudsim.utilizationmodels.UtilizationModel;
import org.cloudbus.cloudsim.utilizationmodels.UtilizationModelFull; import org.cloudbus.cloudsim.utilizationmodels.UtilizationModelFull;
...@@ -66,7 +68,8 @@ public class VmAllocationPolicyMigrationSlaExample { ...@@ -66,7 +68,8 @@ public class VmAllocationPolicyMigrationSlaExample {
simulation = new CloudSim(); simulation = new CloudSim();
datacenter0 = createDatacenter(); datacenter0 = createDatacenter();
//Creates a broker that is a software acting on behalf a cloud customer to manage his/her VMs and Cloudlets // Creates a broker that is a software acting on behalf a cloud customer to
// manage his/her VMs and Cloudlets
broker0 = new DatacenterBrokerSimple(simulation); broker0 = new DatacenterBrokerSimple(simulation);
vmList = createVms(); vmList = createVms();
...@@ -86,31 +89,51 @@ public class VmAllocationPolicyMigrationSlaExample { ...@@ -86,31 +89,51 @@ public class VmAllocationPolicyMigrationSlaExample {
*/ */
private Datacenter createDatacenter() { private Datacenter createDatacenter() {
final List<Host> hostList = new ArrayList<>(HOSTS); final List<Host> hostList = new ArrayList<>(HOSTS);
for(int i = 0; i < HOSTS; i++) { final int hostId = 0;
Host host = createHost();
hostList.add(host); createHosts(LOOSE, HOSTS, hostList, hostId);
} createHosts(TIGHT, HOSTS, hostList, hostId);
final Datacenter dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicyFirstFit()); final Datacenter dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicyFirstFit());
return dc; return dc;
} }
private Host createHost() { private void createHosts(String slaExploitationPolicy, int numberOfHeavenHosts, List<Host> hostList, int hostId) {
for (int i = 0; i < numberOfHeavenHosts; i++) {
Host host = createHost(slaExploitationPolicy);
hostList.add(host);
host.setId(i);
}
}
private Host createHost(String slaExploitationPolicy) {
List<Pe> peList = new ArrayList<>(HOST_PES); List<Pe> peList = new ArrayList<>(HOST_PES);
//List of Host's CPUs (Processing Elements, PEs) // List of Host's CPUs (Processing Elements, PEs)
for (int i = 0; i < HOST_PES; i++) { for (int i = 0; i < HOST_PES; i++) {
peList.add(new PeSimple(1000, new PeProvisionerSimple())); peList.add(new PeSimple(1000, new PeProvisionerSimple()));
} }
final long ram = 2048; //in Megabytes final long ram = 2048; // in Megabytes
final long bw = 10000; //in Megabits/s final long bw = 10000; // in Megabits/s
final long storage = 1000000; //in Megabytes final long storage = 1000000; // in Megabytes
final long iops = 20000;
ResourceProvisioner ramProvisioner = new ResourceProvisionerSimple(); ResourceProvisioner ramProvisioner = new ResourceProvisionerSimple();
ResourceProvisioner bwProvisioner = new ResourceProvisionerSimple(); ResourceProvisioner bwProvisioner = new ResourceProvisionerSimple();
VmScheduler vmScheduler = new VmSchedulerTimeShared(); VmScheduler vmScheduler = new VmSchedulerSpaceShared();
Host host = new HostSimple(ram, bw, storage, peList);
Host host = new HostSimple(ram, iops, bw, storage, peList).setRamProvisioner(ramProvisioner)
.setBwProvisioner(bwProvisioner).setVmScheduler(vmScheduler);
host.setRamProvisioner(ramProvisioner).setBwProvisioner(bwProvisioner).setVmScheduler(vmScheduler); switch (slaExploitationPolicy) {
case LOOSE:
host.setIopsProvisioner(new ResourceProvisionerSimple());
break;
case TIGHT:
host.setIopsProvisioner(new ResourceProvisionerShared());
break;
}
return host; return host;
} }
...@@ -121,9 +144,7 @@ public class VmAllocationPolicyMigrationSlaExample { ...@@ -121,9 +144,7 @@ public class VmAllocationPolicyMigrationSlaExample {
private List<Vm> createVms() { private List<Vm> createVms() {
final List<Vm> list = new ArrayList<>(VMS); final List<Vm> list = new ArrayList<>(VMS);
for (int i = 0; i < VMS; i++) { for (int i = 0; i < VMS; i++) {
Vm vm = Vm vm = new VmSimple(i, 1000, VM_PES).setRam(512).setBw(1000).setSize(10000)
new VmSimple(i, 1000, VM_PES)
.setRam(512).setBw(1000).setSize(10000)
.setCloudletScheduler(new CloudletSchedulerTimeShared()); .setCloudletScheduler(new CloudletSchedulerTimeShared());
list.add(vm); list.add(vm);
...@@ -139,11 +160,8 @@ public class VmAllocationPolicyMigrationSlaExample { ...@@ -139,11 +160,8 @@ public class VmAllocationPolicyMigrationSlaExample {
final List<Cloudlet> list = new ArrayList<>(CLOUDLETS); final List<Cloudlet> list = new ArrayList<>(CLOUDLETS);
UtilizationModel utilization = new UtilizationModelFull(); UtilizationModel utilization = new UtilizationModelFull();
for (int i = 0; i < CLOUDLETS; i++) { for (int i = 0; i < CLOUDLETS; i++) {
Cloudlet cloudlet = Cloudlet cloudlet = new CloudletSimple(i, CLOUDLET_LENGTH, CLOUDLET_PES).setFileSize(1024)
new CloudletSimple(i, CLOUDLET_LENGTH, CLOUDLET_PES) .setOutputSize(1024).setUtilizationModel(utilization);
.setFileSize(1024)
.setOutputSize(1024)
.setUtilizationModel(utilization);
list.add(cloudlet); list.add(cloudlet);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment