Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StartExperimentSFCEdge.java file potential bug or intended feature #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added jars/cloudsim-4.0.jar
Binary file not shown.
Binary file added jars/cloudsim-examples-4.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

package org.cloudbus.cloudsim.sdn;

import java.util.List;

import org.cloudbus.cloudsim.Cloudlet;

import java.util.List;

public interface CloudletSchedulerMonitor {
public long getTotalProcessingPreviousTime(double currentTime, List<Double> mipsShare);
public boolean isVmIdle();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cloudbus/cloudsim/sdn/LogWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void print(String s) {

public void printLine() {
if(out == null)
System.err.println("");
System.err.println();
else
out.println();
}
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/org/cloudbus/cloudsim/sdn/example/SimpleExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void main(String[] args) {
workloads.add(args[i]);
}
else
workloads = (List<String>) Arrays.asList(workload_files);
workloads = Arrays.asList(workload_files);

printArguments(physicalTopologyFile, deploymentFile, workloads);
Log.printLine("Starting CloudSim SDN...");
Expand All @@ -112,31 +112,23 @@ public static void main(String[] args) {
switch(vmAllocPolicy) {
case CombMFF:
case MFF:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> hostList) { return new VmAllocationPolicyCombinedMostFullFirst(hostList); }
};
vmAllocationFac = VmAllocationPolicyCombinedMostFullFirst::new;
PhysicalTopologyParser.loadPhysicalTopologySingleDC(physicalTopologyFile, nos, hsFac);
ls = new LinkSelectionPolicyDestinationAddress();
break;
case CombLFF:
case LFF:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> hostList) { return new VmAllocationPolicyCombinedLeastFullFirst(hostList); }
};
vmAllocationFac = hostList -> new VmAllocationPolicyCombinedLeastFullFirst(hostList);
PhysicalTopologyParser.loadPhysicalTopologySingleDC(physicalTopologyFile, nos, hsFac);
ls = new LinkSelectionPolicyDestinationAddress();
break;
case MipMFF:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> hostList) { return new VmAllocationPolicyMipsMostFullFirst(hostList); }
};
vmAllocationFac = hostList -> new VmAllocationPolicyMipsMostFullFirst(hostList);
PhysicalTopologyParser.loadPhysicalTopologySingleDC(physicalTopologyFile, nos, hsFac);
ls = new LinkSelectionPolicyDestinationAddress();
break;
case MipLFF:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> hostList) { return new VmAllocationPolicyMipsLeastFullFirst(hostList); }
};
vmAllocationFac = hostList -> new VmAllocationPolicyMipsLeastFullFirst(hostList);
PhysicalTopologyParser.loadPhysicalTopologySingleDC(physicalTopologyFile, nos, hsFac);
ls = new LinkSelectionPolicyDestinationAddress();
break;
Expand All @@ -160,7 +152,9 @@ public static void main(String[] args) {

// Broker
SDNBroker broker = createBroker();
int brokerId = broker.getId();
if (broker != null) {
int brokerId = broker.getId();
}

// Submit virtual topology
broker.submitDeployApplication(datacenter, deploymentFile);
Expand Down Expand Up @@ -274,7 +268,7 @@ protected static SDNDatacenter createSDNDatacenter(String name, String physicalT
* @return the datacenter broker
*/
protected static SDNBroker createBroker() {
SDNBroker broker = null;
SDNBroker broker;
try {
broker = new SDNBroker("Broker");
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static void main(String[] args) throws FileNotFoundException {
}
}
else {
workloads = (List<String>) Arrays.asList(workload_files);
workloads = Arrays.asList(workload_files);
}

FileOutputStream output = new FileOutputStream(Configuration.workingDirectory+Configuration.experimentName+"log.out.txt");
Expand Down Expand Up @@ -232,8 +232,8 @@ public VmAllocationPolicy create(List<? extends Host> list,
public VmAllocationPolicy create(List<? extends Host> list,
HostSelectionPolicy hostSelectionPolicy,
VmMigrationPolicy vmMigrationPolicy
) {
return new VmAllocationPolicyCombinedLeastFullFirst(list);
) {
return new VmAllocationPolicyCombinedLeastFullFirst(list);
}
};
nos = new NetworkOperatingSystemSimple();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static void main(String[] args) throws FileNotFoundException {
}
}
else {
workloads = (List<String>) Arrays.asList(workload_files);
workloads = Arrays.asList(workload_files);
}

FileOutputStream output = new FileOutputStream(Configuration.workingDirectory+Configuration.experimentName+"log.out.txt");
Expand Down Expand Up @@ -338,7 +338,9 @@ public VmAllocationPolicy create(List<? extends Host> list,

// Broker
SDNBroker broker = createBroker();
int brokerId = broker.getId();
if (broker != null) {
int brokerId = broker.getId();
}

// Submit virtual topology
broker.submitDeployApplication(datacenter, deploymentFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static void main(String[] args) throws FileNotFoundException {
}
}
else {
workloads = (List<String>) Arrays.asList(workload_files);
workloads = Arrays.asList(workload_files);
}

FileOutputStream output = new FileOutputStream(Configuration.workingDirectory+Configuration.experimentName+"log.out.txt");
Expand All @@ -208,55 +208,27 @@ public static void main(String[] args) throws FileNotFoundException {
switch(vmAllocPolicy) {
case Random:
case RandomFlow:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> list,
HostSelectionPolicy hostSelectionPolicy,
VmMigrationPolicy vmMigrationPolicy
) {
return new VmAllocationPolicyCombinedLeastFullFirst(list);
}
};
vmAllocationFac = (list, hostSelectionPolicy1, vmMigrationPolicy1) -> new VmAllocationPolicyCombinedLeastFullFirst(list);
nos = new NetworkOperatingSystemSimple();
break;
case MFF:
case MFFFlow:
case MFFCPU:
case MFFBW:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> list,
HostSelectionPolicy hostSelectionPolicy,
VmMigrationPolicy vmMigrationPolicy
) {
return new VmAllocationPolicyCombinedMostFullFirst(list);
}
};
vmAllocationFac = (list, hostSelectionPolicy12, vmMigrationPolicy12) -> new VmAllocationPolicyCombinedMostFullFirst(list);
nos = new NetworkOperatingSystemSimple();
break;
case LFF:
case LFFFlow:
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> list,
HostSelectionPolicy hostSelectionPolicy,
VmMigrationPolicy vmMigrationPolicy
) {
return new VmAllocationPolicyCombinedLeastFullFirst(list);
}
};
vmAllocationFac = (list, hostSelectionPolicy13, vmMigrationPolicy13) -> new VmAllocationPolicyCombinedLeastFullFirst(list);
nos = new NetworkOperatingSystemSimple();
break;
case HPF: // High Priority First
case HPFFlow:
// Initial placement: overbooking, MFF
// Initial placement connectivity: Connected VMs in one host
// Migration: none
vmAllocationFac = new VmAllocationPolicyFactory() {
public VmAllocationPolicy create(List<? extends Host> list,
HostSelectionPolicy hostSelectionPolicy,
VmMigrationPolicy vmMigrationPolicy
) {
return new VmAllocationPolicyPriorityFirst(list, hostSelectionPolicy, vmMigrationPolicy);
}
};
vmAllocationFac = (list, hostSelectionPolicy14, vmMigrationPolicy14) -> new VmAllocationPolicyPriorityFirst(list, hostSelectionPolicy14, vmMigrationPolicy14);
nos = new NetworkOperatingSystemGroupPriority();
hostSelectionPolicy = new HostSelectionPolicyMostFull();
vmMigrationPolicy = null;
Expand Down Expand Up @@ -301,7 +273,9 @@ public VmAllocationPolicy create(List<? extends Host> list,

// Broker
SDNBroker broker = createBroker();
int brokerId = broker.getId();
if (broker != null) {
int brokerId = broker.getId();
}

// Submit virtual topology
broker.submitDeployApplication(dcs.values(), deploymentFile);
Expand Down Expand Up @@ -368,12 +342,14 @@ public static Map<NetworkOperatingSystem, SDNDatacenter> createPhysicalTopology(
HostSelectionPolicy hostSelectionPolicy,
VmMigrationPolicy vmMigrationPolicy) {
HashMap<NetworkOperatingSystem, SDNDatacenter> dcs = new HashMap<NetworkOperatingSystem, SDNDatacenter>();
// This funciton creates Datacenters and NOS inside the data cetner.
// This funciton creates Datacenters and NOS inside the data center.
Map<String, NetworkOperatingSystem> dcNameNOS = PhysicalTopologyParser.loadPhysicalTopologyMultiDC(physicalTopologyFile);

for(String dcName:dcNameNOS.keySet()) {
NetworkOperatingSystem nos = dcNameNOS.get(dcName);
nos.setLinkSelectionPolicy(ls);
//if ("net".equals(dcName)) continue;
if (!nos.getPhysicalTopology().isCloudNode()) continue;
SDNDatacenter datacenter = createSDNDatacenter(dcName, nos, vmAllocationFac, hostSelectionPolicy,
vmMigrationPolicy);

Expand Down Expand Up @@ -458,7 +434,7 @@ protected static SDNDatacenter createSDNDatacenter(String name,
* @return the datacenter broker
*/
protected static SDNBroker createBroker() {
SDNBroker broker = null;
SDNBroker broker;
try {
broker = new SDNBroker("Broker");
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public List<Double> getValues() {

do {
// Calculate the average values between start and end time
endInterval = endInterval > endTime ? endTime : endInterval;
endInterval = Math.min(endInterval, endTime);
double sum = 0;
double totalDuration = 0;
double t_prev = startInterval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ private void updateVmMonitor(double logTime) {
if(vmAlloc instanceof OverbookingVmAllocationPolicy) {
for(Vm v: this.vmMapId2Vm.values()) {
SDNVm vm = (SDNVm)v;
double mipsOBR = ((OverbookingVmAllocationPolicy)vmAlloc).getCurrentOverbookingRatioMips((SDNVm) vm);
double mipsOBR = ((OverbookingVmAllocationPolicy)vmAlloc).getCurrentOverbookingRatioMips(vm);
LogWriter log = LogWriter.getLogger("vm_OBR_mips.csv");
log.printLine(vm.getName()+","+logTime+","+mipsOBR);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ protected List<VmGroup> createVmGroup(Collection<Vm> vms, Collection<FlowConfig>
List<FlowConfig> arcPool = new ArrayList<FlowConfig>(flows); // all virtual Links

// Sort links by their bandwidth
Collections.sort(arcPool, new Comparator<FlowConfig>() {
public int compare(FlowConfig o1, FlowConfig o2) {
return (int) (o1.getBw() - o2.getBw());
}
});
Collections.sort(arcPool, (o1, o2) -> (int) (o1.getBw() - o2.getBw()));

// Separate groups by link bandwidth order
List<VmGroup> groups = VmGroupPriority.classifyGroupByArcList(arcPool, vmPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ protected boolean deployApplication(List<Vm> vms, Collection<FlowConfig> links,
Log.printLine(CloudSim.clock() + ": " + getName() + ": Starting deploying application..");

// Sort VMs in decending order of the required MIPS
Collections.sort(vms, new Comparator<Vm>() {
public int compare(Vm o1, Vm o2) {
return (int) (o2.getMips()*o2.getNumberOfPes() - o1.getMips()*o1.getNumberOfPes());
}
});
Collections.sort(vms, (o1, o2) -> (int) (o2.getMips()*o2.getNumberOfPes() - o1.getMips()*o1.getNumberOfPes()));


for(Vm vm:vms)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static Map<String, NetworkOperatingSystem> loadPhysicalTopologyMultiDC(St
for(String dcName: dcNameType.keySet()) {
NetworkOperatingSystem nos;
nos = new NetworkOperatingSystemSimple("NOS_"+dcName);

netOsList.put(dcName, nos);
parser.parseNode(dcName);
}
Expand All @@ -85,6 +85,8 @@ public static Map<String, NetworkOperatingSystem> loadPhysicalTopologyMultiDC(St
}
for(String dcName: dcNameType.keySet()) {
if("network".equals(dcNameType.get(dcName))) {
//potential bug: why do same operations for different type of dcNameType? This results in "net" to gain zero
//nodeTable
NetworkOperatingSystem nos = netOsList.get(dcName);
nos.configurePhysicalTopology(parser.getHosts(dcName), parser.getSwitches(dcName), parser.getLinks());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void addLink(Node fromNode, Node toNode, double latency){
int from = fromNode.getAddress();
int to = toNode.getAddress();

long bw = (fromNode.getBandwidth()<toNode.getBandwidth())? fromNode.getBandwidth():toNode.getBandwidth();
long bw = Math.min(fromNode.getBandwidth(), toNode.getBandwidth());

if(!nodesTable.containsKey(from)||!nodesTable.containsKey(to)){
throw new IllegalArgumentException("Unknown node on link:"+nodesTable.get(from).getAddress()+"->"+nodesTable.get(to).getAddress());
Expand Down Expand Up @@ -212,6 +212,15 @@ public Collection<Switch> getAllSwitches() {
}
return allSwitches;
}

public boolean isCloudNode(){

for(Node n:nodesTable.values()) {
if(n instanceof SDNHost)
return true;
}
return false;
}

public Collection<SDNHost> getAllHosts() {
Collection<SDNHost> allHosts = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ protected double getOverRatioBw(SDNVm vm, Host host) {

public void updateResourceAllocation(Host host) {
// Update the resource allocation ratio of every VM
return;
}

// Temporary resource reservation for migration purpose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public static void classifyGroupByArcList(List<FlowConfig> sortedArcPool, List<V
if(dstVm != null) {
// dst vm is not grouped yet. put dst into the same group
vmGroup = findVmGroup(groups, a.getSrcId());
vmGroup.addVm(dstVm);
if (vmGroup != null) {
vmGroup.addVm(dstVm);
}
}
else {
// dst vm is also already grouped. both are in group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,13 @@ protected List<SDNVm> getMostUtilizedVms(List<SDNHost> hosts) {
}

// Sort the most utilized VMs
Collections.sort(migrationOverVMList, new Comparator<SDNVm>() {
public int compare(SDNVm o1, SDNVm o2) {
double endTime = CloudSim.clock();
double startTime = endTime - Configuration.migrationTimeInterval;

double o1util = o1.getMonitoringValuesVmCPUUtilization().getAverageValue(startTime, endTime);
double o2util = o2.getMonitoringValuesVmCPUUtilization().getAverageValue(startTime, endTime);
return (int) (o1util - o2util);
}
Collections.sort(migrationOverVMList, (o1, o2) -> {
double endTime = CloudSim.clock();
double startTime = endTime - Configuration.migrationTimeInterval;

double o1util = o1.getMonitoringValuesVmCPUUtilization().getAverageValue(startTime, endTime);
double o2util = o2.getMonitoringValuesVmCPUUtilization().getAverageValue(startTime, endTime);
return (int) (o1util - o2util);
});

return migrationOverVMList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public boolean allocateHostForVmInGroup(Vm vm, VmGroup vmGroup) {
else {
// Other VMs in the group has been already allocated
// Avoid the correlated hosts.
List<SDNHost> allHosts = new ArrayList<SDNHost>(this.<SDNHost>getHostList());
List<SDNHost> allHosts = new ArrayList<SDNHost>(this.getHostList());
allHosts.removeAll(connectedHosts);

if(allocateHostForVm(vm, hostSelectionPolicy.selectHostForVm((SDNVm)vm, allHosts)) == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ protected static <T extends Host> List<T> sortLeastCorrelatedHosts(SDNVm vm, Li
}

// Sort the most utilized VMs
Collections.sort(hosts, new Comparator<Host>() {
public int compare(Host o1, Host o2) {
double o1cc = corr.get(o1);
double o2cc = corr.get(o2);
return Double.compare(o1cc, o2cc);
}
Collections.sort(hosts, (Comparator<Host>) (o1, o2) -> {
double o1cc = corr.get(o1);
double o2cc = corr.get(o2);
return Double.compare(o1cc, o2cc);
});
return (List<T>) hosts;
}
Expand Down