Commit 0565205c authored by Rodrigo's avatar Rodrigo
parents 93c1e74f dff82476
...@@ -11,6 +11,10 @@ package org.cloudbus.cloudsim.examples.container; ...@@ -11,6 +11,10 @@ package org.cloudbus.cloudsim.examples.container;
*/ */
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModelNull;
import org.cloudbus.cloudsim.container.containerProvisioners.ContainerBwProvisionerSimple; import org.cloudbus.cloudsim.container.containerProvisioners.ContainerBwProvisionerSimple;
import org.cloudbus.cloudsim.container.containerProvisioners.ContainerPe; import org.cloudbus.cloudsim.container.containerProvisioners.ContainerPe;
import org.cloudbus.cloudsim.container.containerProvisioners.ContainerRamProvisionerSimple; import org.cloudbus.cloudsim.container.containerProvisioners.ContainerRamProvisionerSimple;
...@@ -32,10 +36,9 @@ import org.cloudbus.cloudsim.container.schedulers.ContainerVmSchedulerTimeShared ...@@ -32,10 +36,9 @@ import org.cloudbus.cloudsim.container.schedulers.ContainerVmSchedulerTimeShared
import org.cloudbus.cloudsim.container.utils.IDs; import org.cloudbus.cloudsim.container.utils.IDs;
import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicy; import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicy;
import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicyMaximumUsage; import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicyMaximumUsage;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.core.CloudSim; import org.cloudbus.cloudsim.core.CloudSim;
import java.io.*; import java.io.FileNotFoundException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
...@@ -132,9 +135,9 @@ public class ContainerCloudSimExample1 { ...@@ -132,9 +135,9 @@ public class ContainerCloudSimExample1 {
* 6- The host list is created considering the number of hosts, and host types which are specified * 6- The host list is created considering the number of hosts, and host types which are specified
* in the {@link ConstantsExamples}. * in the {@link ConstantsExamples}.
*/ */
hostList = new ArrayList<>(); hostList = new ArrayList<ContainerHost>();
hostList = createHostList(ConstantsExamples.NUMBER_HOSTS); hostList = createHostList(ConstantsExamples.NUMBER_HOSTS);
cloudletList = new ArrayList<>(); cloudletList = new ArrayList<ContainerCloudlet>();
vmList = new ArrayList<ContainerVm>(); vmList = new ArrayList<ContainerVm>();
/** /**
* 7- The container allocation policy which defines the allocation of VMs to containers. * 7- The container allocation policy which defines the allocation of VMs to containers.
...@@ -163,7 +166,9 @@ public class ContainerCloudSimExample1 { ...@@ -163,7 +166,9 @@ public class ContainerCloudSimExample1 {
@SuppressWarnings("unused") @SuppressWarnings("unused")
PowerContainerDatacenter e = (PowerContainerDatacenter) createDatacenter("datacenter", PowerContainerDatacenter e = (PowerContainerDatacenter) createDatacenter("datacenter",
PowerContainerDatacenterCM.class, hostList, vmAllocationPolicy, containerAllocationPolicy, PowerContainerDatacenterCM.class, hostList, vmAllocationPolicy, containerAllocationPolicy,
getExperimentName("ContainerCloudSimExample-1", String.valueOf(overBookingFactor)), logAddress); getExperimentName("ContainerCloudSimExample-1", String.valueOf(overBookingFactor)),
ConstantsExamples.SCHEDULING_INTERVAL, logAddress,
ConstantsExamples.VM_STARTTUP_DELAY, ConstantsExamples.CONTAINER_STARTTUP_DELAY);
/** /**
...@@ -351,7 +356,8 @@ public class ContainerCloudSimExample1 { ...@@ -351,7 +356,8 @@ public class ContainerCloudSimExample1 {
List<ContainerHost> hostList, List<ContainerHost> hostList,
ContainerVmAllocationPolicy vmAllocationPolicy, ContainerVmAllocationPolicy vmAllocationPolicy,
ContainerAllocationPolicy containerAllocationPolicy, ContainerAllocationPolicy containerAllocationPolicy,
String experimentName, String logAddress) throws Exception { String experimentName, double schedulingInterval, String logAddress, double VMStartupDelay,
double ContainerStartupDelay) throws Exception {
String arch = "x86"; String arch = "x86";
String os = "Linux"; String os = "Linux";
String vmm = "Xen"; String vmm = "Xen";
...@@ -361,27 +367,11 @@ public class ContainerCloudSimExample1 { ...@@ -361,27 +367,11 @@ public class ContainerCloudSimExample1 {
double costPerStorage = 0.001D; double costPerStorage = 0.001D;
double costPerBw = 0.0D; double costPerBw = 0.0D;
ContainerDatacenterCharacteristics characteristics = new ContainerDatacenterCharacteristics characteristics = new
ContainerDatacenterCharacteristics(arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw); ContainerDatacenterCharacteristics(arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage,
ContainerDatacenter datacenter = null; costPerBw);
try { ContainerDatacenter datacenter = new PowerContainerDatacenterCM(name, characteristics, vmAllocationPolicy,
datacenter = datacenterClass.getConstructor( containerAllocationPolicy, new LinkedList<Storage>(), schedulingInterval, experimentName, logAddress,
String.class, VMStartupDelay, ContainerStartupDelay);
ContainerDatacenterCharacteristics.class,
ContainerVmAllocationPolicy.class,
ContainerAllocationPolicy.class,
List.class,
Double.TYPE, String.class, String.class
).newInstance(
name,
characteristics,
vmAllocationPolicy,
containerAllocationPolicy,
new LinkedList<Storage>(),
ConstantsExamples.SCHEDULING_INTERVAL, experimentName, logAddress);
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
return datacenter; return datacenter;
} }
......
package org.cloudbus.cloudsim.container.core; package org.cloudbus.cloudsim.container.core;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.container.resourceAllocators.ContainerAllocationPolicy; import org.cloudbus.cloudsim.container.resourceAllocators.ContainerAllocationPolicy;
import org.cloudbus.cloudsim.container.resourceAllocators.ContainerVmAllocationPolicy; import org.cloudbus.cloudsim.container.resourceAllocators.ContainerVmAllocationPolicy;
import org.cloudbus.cloudsim.container.utils.CostumeCSVWriter; import org.cloudbus.cloudsim.container.utils.CostumeCSVWriter;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.core.CloudSim; import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.core.CloudSimTags; import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
import org.cloudbus.cloudsim.core.predicates.PredicateType; import org.cloudbus.cloudsim.core.predicates.PredicateType;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Created by sareh on 3/08/15. * Created by sareh on 3/08/15.
...@@ -25,15 +28,15 @@ public class PowerContainerDatacenterCM extends PowerContainerDatacenter { ...@@ -25,15 +28,15 @@ public class PowerContainerDatacenterCM extends PowerContainerDatacenter {
private CostumeCSVWriter newlyCreatedVmWriter; private CostumeCSVWriter newlyCreatedVmWriter;
private int newlyCreatedVms; private int newlyCreatedVms;
private List<Integer> newlyCreatedVmsList; private List<Integer> newlyCreatedVmsList;
private int vmStartupDelay; private double vmStartupDelay;
private int containerStartupDelay; private double containerStartupDelay;
public PowerContainerDatacenterCM(String name, ContainerDatacenterCharacteristics characteristics, public PowerContainerDatacenterCM(String name, ContainerDatacenterCharacteristics characteristics,
ContainerVmAllocationPolicy vmAllocationPolicy, ContainerVmAllocationPolicy vmAllocationPolicy,
ContainerAllocationPolicy containerAllocationPolicy, List<Storage> storageList, ContainerAllocationPolicy containerAllocationPolicy, List<Storage> storageList,
double schedulingInterval, String experimentName, String logAddress, double schedulingInterval, String experimentName, String logAddress,
int vmStartupDelay, int containerStartupDelay) throws Exception { double vmStartupDelay, double containerStartupDelay) throws Exception {
super(name, characteristics, vmAllocationPolicy, containerAllocationPolicy, storageList, schedulingInterval, experimentName, logAddress); super(name, characteristics, vmAllocationPolicy, containerAllocationPolicy, storageList, schedulingInterval, experimentName, logAddress);
String newlyCreatedVmsAddress; String newlyCreatedVmsAddress;
int index = getExperimentName().lastIndexOf("_"); int index = getExperimentName().lastIndexOf("_");
...@@ -69,7 +72,7 @@ public class PowerContainerDatacenterCM extends PowerContainerDatacenter { ...@@ -69,7 +72,7 @@ public class PowerContainerDatacenterCM extends PowerContainerDatacenter {
int previousContainerMigrationCount = getContainerMigrationCount(); int previousContainerMigrationCount = getContainerMigrationCount();
int previousVmMigrationCount = getVmMigrationCount(); int previousVmMigrationCount = getVmMigrationCount();
if (migrationMap != null) { if (migrationMap != null) {
List<ContainerVm> vmList = new ArrayList<>(); List<ContainerVm> vmList = new ArrayList<ContainerVm>();
for (Map<String, Object> migrate : migrationMap) { for (Map<String, Object> migrate : migrationMap) {
if (migrate.containsKey("container")) { if (migrate.containsKey("container")) {
Container container = (Container) migrate.get("container"); Container container = (Container) migrate.get("container");
...@@ -240,7 +243,7 @@ public class PowerContainerDatacenterCM extends PowerContainerDatacenter { ...@@ -240,7 +243,7 @@ public class PowerContainerDatacenterCM extends PowerContainerDatacenter {
// containerVm.addMigratingInContainer((Container) map.get("container")); // containerVm.addMigratingInContainer((Container) map.get("container"));
ack = true; ack = true;
if (ack) { if (ack) {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<String, Object>();
data.put("vm", containerVm); data.put("vm", containerVm);
data.put("result", containerVm); data.put("result", containerVm);
data.put("datacenterID", getId()); data.put("datacenterID", getId());
......
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