Commit 91d6521c authored by sarehfotuhi's avatar sarehfotuhi

ContainerExamples

parent dff82476
package org.cloudbus.cloudsim.examples.container;
import com.opencsv.CSVWriter;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.container.containerProvisioners.ContainerBwProvisionerSimple;
import org.cloudbus.cloudsim.container.containerProvisioners.ContainerPe;
import org.cloudbus.cloudsim.container.containerProvisioners.ContainerRamProvisionerSimple;
......@@ -16,8 +18,6 @@ import org.cloudbus.cloudsim.container.schedulers.ContainerCloudletSchedulerDyna
import org.cloudbus.cloudsim.container.schedulers.ContainerSchedulerTimeSharedOverSubscription;
import org.cloudbus.cloudsim.container.schedulers.ContainerVmSchedulerTimeSharedOverSubscription;
import org.cloudbus.cloudsim.container.utils.IDs;
import com.opencsv.CSVWriter;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.util.MathUtil;
import java.io.*;
......@@ -178,7 +178,63 @@ public class HelperEx {
// return datacenter;
// }
// Data Center
public static ContainerDatacenter createDatacenter(String name, Class<? extends ContainerDatacenter> datacenterClass, List<ContainerHost> hostList, ContainerVmAllocationPolicy vmAllocationPolicy, ContainerAllocationPolicy containerAllocationPolicy, String experimentName, String logAddress) throws Exception {
// public static ContainerDatacenter createDatacenter(String name, Class<? extends ContainerDatacenter> datacenterClass, List<ContainerHost> hostList, ContainerVmAllocationPolicy vmAllocationPolicy, ContainerAllocationPolicy containerAllocationPolicy, String experimentName, String logAddress) throws Exception {
// String arch = "x86";
// String os = "Linux";
// String vmm = "Xen";
// double time_zone = 10.0D;
// double cost = 3.0D;
// double costPerMem = 0.05D;
// double costPerStorage = 0.001D;
// double costPerBw = 0.0D;
// ContainerDatacenterCharacteristics characteristics = new ContainerDatacenterCharacteristics(arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw);
// ContainerDatacenter datacenter = null;
// try {
// datacenter = datacenterClass.getConstructor(
// String.class,
// 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);
// }
//// datacenter = new PowerContainerDatacenter(name,characteristics, vmAllocationPolicy, containerAllocationPolicy , new LinkedList(),Double.valueOf(300.0D));
//// datacenter = new PowerContainerDatacenterCM(name,characteristics, vmAllocationPolicy, containerAllocationPolicy , new LinkedList(),Double.valueOf(300.0D));
//
// return datacenter;
// }
/**
* Create the data center
*
* @param name
* @param datacenterClass
* @param hostList
* @param vmAllocationPolicy
* @param containerAllocationPolicy
* @param experimentName
* @param logAddress
* @return
* @throws Exception
*/
public static ContainerDatacenter createDatacenter(String name, Class<? extends ContainerDatacenter> datacenterClass,
List<ContainerHost> hostList,
ContainerVmAllocationPolicy vmAllocationPolicy,
ContainerAllocationPolicy containerAllocationPolicy,
String experimentName, double schedulingInterval, String logAddress, double VMStartupDelay,
double ContainerStartupDelay) throws Exception {
String arch = "x86";
String os = "Linux";
String vmm = "Xen";
......@@ -187,34 +243,15 @@ public class HelperEx {
double costPerMem = 0.05D;
double costPerStorage = 0.001D;
double costPerBw = 0.0D;
ContainerDatacenterCharacteristics characteristics = new ContainerDatacenterCharacteristics(arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw);
ContainerDatacenter datacenter = null;
try {
datacenter = datacenterClass.getConstructor(
String.class,
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);
}
// datacenter = new PowerContainerDatacenter(name,characteristics, vmAllocationPolicy, containerAllocationPolicy , new LinkedList(),Double.valueOf(300.0D));
// datacenter = new PowerContainerDatacenterCM(name,characteristics, vmAllocationPolicy, containerAllocationPolicy , new LinkedList(),Double.valueOf(300.0D));
ContainerDatacenterCharacteristics characteristics = new
ContainerDatacenterCharacteristics(arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage,
costPerBw);
ContainerDatacenter datacenter = new PowerContainerDatacenterCM(name, characteristics, vmAllocationPolicy,
containerAllocationPolicy, new LinkedList<Storage>(), schedulingInterval, experimentName, logAddress,
VMStartupDelay, ContainerStartupDelay);
return datacenter;
}
/**
* Prints the results.
*
......
package org.cloudbus.cloudsim.examples.container;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.container.containerPlacementPolicies.*;
import org.cloudbus.cloudsim.container.containerSelectionPolicies.PowerContainerSelectionPolicy;
import org.cloudbus.cloudsim.container.containerSelectionPolicies.PowerContainerSelectionPolicyCor;
......@@ -9,13 +10,19 @@ import org.cloudbus.cloudsim.container.hostSelectionPolicies.*;
import org.cloudbus.cloudsim.container.resourceAllocatorMigrationEnabled.PowerContainerVmAllocationPolicyMigrationAbstractHostSelection;
import org.cloudbus.cloudsim.container.resourceAllocatorMigrationEnabled.PowerContainerVmAllocationPolicyMigrationStaticThresholdMC;
import org.cloudbus.cloudsim.container.resourceAllocatorMigrationEnabled.PowerContainerVmAllocationPolicyMigrationStaticThresholdMCUnderUtilized;
import org.cloudbus.cloudsim.container.resourceAllocators.*;
import org.cloudbus.cloudsim.container.resourceAllocators.ContainerAllocationPolicy;
import org.cloudbus.cloudsim.container.resourceAllocators.ContainerAllocationPolicyRS;
import org.cloudbus.cloudsim.container.resourceAllocators.ContainerVmAllocationPolicy;
import org.cloudbus.cloudsim.container.resourceAllocators.PowerContainerAllocationPolicySimple;
import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicy;
import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicyMaximumCorrelation;
import org.cloudbus.cloudsim.container.vmSelectionPolicies.PowerContainerVmSelectionPolicyMaximumUsage;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.core.CloudSim;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
/**
......@@ -164,7 +171,10 @@ public abstract class RunnerAbs {
System.out.println("Starting " + experimentName);
try {
PowerContainerDatacenter e = (PowerContainerDatacenter) HelperEx.createDatacenter("datacenter", PowerContainerDatacenterCM.class, hostList, vmAllocationPolicy, containerAllocationPolicy, getExperimentName(), getLogAddress());
PowerContainerDatacenter e = (PowerContainerDatacenter) HelperEx.createDatacenter("datacenter",
PowerContainerDatacenterCM.class, hostList, vmAllocationPolicy, containerAllocationPolicy,
getExperimentName(), ConstantsExamples.SCHEDULING_INTERVAL, getLogAddress(),
ConstantsExamples.VM_STARTTUP_DELAY, ConstantsExamples.CONTAINER_STARTTUP_DELAY);
// PowerContainerDatacenter e = (PowerContainerDatacenter) HelperEx.createDatacenter("Datacenter", PowerContainerDatacenter.class, hostList, vmAllocationPolicy, containerAllocationPolicy);
vmAllocationPolicy.setDatacenter(e);
e.setDisableVmMigrations(false);
......
package org.cloudbus.cloudsim.container.resourceAllocators;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.container.core.ContainerHost;
import org.cloudbus.cloudsim.container.core.ContainerVm;
import org.cloudbus.cloudsim.core.CloudSim;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.cloudbus.cloudsim.container.core.ContainerHost;
import org.cloudbus.cloudsim.container.core.ContainerVm;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.core.CloudSim;
/**
* Created by sareh on 14/07/15.
*/
......@@ -115,7 +115,7 @@ public abstract class PowerContainerVmAllocationAbstract extends ContainerVmAll
}
public List<ContainerVm> getOverUtilizedVms() {
List<ContainerVm> vmList = new ArrayList<>();
List<ContainerVm> vmList = new ArrayList<ContainerVm>();
for (ContainerHost host : getContainerHostList()) {
for (ContainerVm vm : host.getVmList()) {
if (vm.getTotalUtilizationOfCpuMips(CloudSim.clock()) > vm.getTotalMips()) {
......
......@@ -22,7 +22,7 @@ public class ContainerVmSchedulerTimeSharedOverSubscription extends ContainerVm
// if the requested mips is bigger than the capacity of a single PE, we cap
// the request to the PE's capacity
List<Double> mipsShareRequestedCapped = new ArrayList<>();
List<Double> mipsShareRequestedCapped = new ArrayList<Double>();
double peMips = getPeCapacity();
for (Double mips : mipsShareRequested) {
if (mips > peMips) {
......
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