Commit 85c0db67 authored by Anton Beloglazov's avatar Anton Beloglazov

- Updated VmSchedulerSpaceShared: respects MIPS specification for VMs

- Removed priority field from the Vm class
parent 2bac5f52
......@@ -84,11 +84,10 @@ public class CloudSimExample1 {
int ram = 512; // vm memory (MB)
long bw = 1000;
int pesNumber = 1; // number of cpus
int priority = 1;
String vmm = "Xen"; // VMM name
// create VM
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
// add the VM to the vmList
vmlist.add(vm);
......
......@@ -29,7 +29,7 @@ import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeSharedWithPriority;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
......@@ -40,7 +40,9 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
* A simple example showing how to create
* a datacenter with one host and run two
* cloudlets on it. The cloudlets run in
* VMs with different priorities.
* VMs with the same MIPS requirements.
* The cloudlets will take the same time to
* complete the execution.
*/
public class CloudSimExample2 {
......@@ -85,16 +87,14 @@ public class CloudSimExample2 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create two VMs
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//the second VM will have twice the priority of VM1 and so will receive twice CPU time
vmid++;
priority = 2;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmList
vmlist.add(vm1);
......@@ -186,7 +186,7 @@ public class CloudSimExample2 {
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeSharedWithPriority(peList)
new VmSchedulerTimeShared(peList)
)
); // This is our machine
......
......@@ -28,7 +28,7 @@ import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeSharedWithPriority;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
......@@ -39,10 +39,10 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
* A simple example showing how to create
* a datacenter with two hosts and run two
* cloudlets on it. The cloudlets run in
* VMs with different priorities. However,
* since each VM run exclusively in each host,
* less priority will not delay the cloudlet
* on it.
* VMs with different MIPS requirements.
* The cloudlets will take different time
* to complete the execution depending on
* the requested VM performance.
*/
public class CloudSimExample3 {
......@@ -82,21 +82,19 @@ public class CloudSimExample3 {
//VM description
int vmid = 0;
int mips = 1000;
int mips = 250;
long size = 10000; //image size (MB)
int ram = 2048; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create two VMs
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//the second VM will have twice the priority of VM1 and so will receive twice CPU time
vmid++;
priority = 2;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority,vmm, new CloudletSchedulerTimeShared());
Vm vm2 = new Vm(vmid, brokerId, mips * 2, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmList
vmlist.add(vm1);
......@@ -187,7 +185,7 @@ public class CloudSimExample3 {
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeSharedWithPriority(peList)
new VmSchedulerTimeShared(peList)
)
); // This is our first machine
......@@ -205,7 +203,7 @@ public class CloudSimExample3 {
new BwProvisionerSimple(bw),
storage,
peList2,
new VmSchedulerTimeSharedWithPriority(peList2)
new VmSchedulerTimeShared(peList2)
)
); // This is our second machine
......
......@@ -84,16 +84,14 @@ public class CloudSimExample4 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create two VMs
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//the second VM will have twice the priority of VM1 and so will receive twice CPU time
vmid++;
priority = 2;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmList
vmlist.add(vm1);
......
......@@ -90,14 +90,13 @@ public class CloudSimExample5 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create two VMs: the first one belongs to user1
Vm vm1 = new Vm(vmid, brokerId1, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId1, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//the second VM: this one belongs to user2
Vm vm2 = new Vm(vmid, brokerId2, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm2 = new Vm(vmid, brokerId2, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmlists
vmlist1.add(vm1);
......
......@@ -58,14 +58,13 @@ public class CloudSimExample6 {
int mips = 250;
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create VMs
Vm[] vm = new Vm[vms];
for(int i=0;i<vms;i++){
vm[i] = new Vm(i, userId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
vm[i] = new Vm(i, userId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//for creating a VM with a space shared scheduling policy for cloudlets:
//vm[i] = Vm(i, userId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerSpaceShared());
......
......@@ -58,14 +58,13 @@ public class CloudSimExample7 {
int mips = 250;
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create VMs
Vm[] vm = new Vm[vms];
for(int i=0;i<vms;i++){
vm[i] = new Vm(idShift + i, userId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
vm[i] = new Vm(idShift + i, userId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
list.add(vm[i]);
}
......
......@@ -60,14 +60,13 @@ public class CloudSimExample8 {
int mips = 250;
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create VMs
Vm[] vm = new Vm[vms];
for(int i=0;i<vms;i++){
vm[i] = new Vm(idShift + i, userId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
vm[i] = new Vm(idShift + i, userId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
list.add(vm[i]);
}
......
......@@ -83,11 +83,10 @@ public class NetworkExample1 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create VM
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VM to the vmList
vmlist.add(vm1);
......
......@@ -30,7 +30,7 @@ import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeSharedWithPriority;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
......@@ -86,16 +86,14 @@ public class NetworkExample2 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create two VMs
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//the second VM will have twice the priority of VM1 and so will receive twice CPU time
vmid++;
priority = 2;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmList
vmlist.add(vm1);
......@@ -209,7 +207,7 @@ public class NetworkExample2 {
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeSharedWithPriority(peList)
new VmSchedulerTimeShared(peList)
)
); // This is our machine
......
......@@ -91,14 +91,13 @@ public class NetworkExample3 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create two VMs: the first one belongs to user1
Vm vm1 = new Vm(vmid, brokerId1, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId1, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//the second VM: this one belongs to user2
Vm vm2 = new Vm(vmid, brokerId2, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm2 = new Vm(vmid, brokerId2, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmlists
vmlist1.add(vm1);
......
......@@ -85,11 +85,10 @@ public class NetworkExample4 {
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
int priority = 1;
String vmm = "Xen"; //VMM name
//create VM
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
//add the VM to the vmList
vmlist.add(vm1);
......
......@@ -197,12 +197,11 @@ public class DVFS {
int ram = 128; // vm memory (MB)
long bw = 2500; // bandwidth
long size = 2500; // image size (MB)
int priority = 1; // image size (MB)
String vmm = "Xen"; // VMM name
for (int i = 0; i < vmsNumber; i++) {
vms.add(
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerSingleService(mips[i % mips.length], pesNumber))
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw, size, vmm, new CloudletSchedulerSingleService(mips[i % mips.length], pesNumber))
);
}
......
......@@ -196,12 +196,11 @@ public class NonPowerAware {
int ram = 128; // vm memory (MB)
long bw = 2500; // bandwidth
long size = 2500; // image size (MB)
int priority = 1; // image size (MB)
String vmm = "Xen"; // VMM name
for (int i = 0; i < vmsNumber; i++) {
vms.add(
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerSingleService(mips[i % mips.length], pesNumber))
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw, size, vmm, new CloudletSchedulerSingleService(mips[i % mips.length], pesNumber))
);
}
......
......@@ -198,12 +198,11 @@ public class SingleThreshold {
int ram = 128; // vm memory (MB)
long bw = 2500; // bandwidth
long size = 2500; // image size (MB)
int priority = 1; // image size (MB)
String vmm = "Xen"; // VMM name
for (int i = 0; i < vmsNumber; i++) {
vms.add(
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw, size, priority, vmm, new CloudletSchedulerSingleService(mips[i % mips.length], pesNumber))
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw, size, vmm, new CloudletSchedulerSingleService(mips[i % mips.length], pesNumber))
);
}
......
......@@ -532,9 +532,6 @@ public class Datacenter extends SimEntity {
Vm vm = (Vm) migrate.get("vm");
Host host = (Host) migrate.get("host");
// if (vm.getId() == 408 && host.getId() == 235) {
// Log.printLine("found");
// }
getVmAllocationPolicy().deallocateHostForVm(vm);
host.removeMigratingInVm(vm);
......
......@@ -46,9 +46,6 @@ public class Vm {
/** The bw. */
private long bw;
/** The priority. */
private int priority;
/** The vmm. */
private String vmm;
......@@ -100,7 +97,7 @@ public class Vm {
* @pre cloudletScheduler != null
* @post $none
*/
public Vm(int id, int userId, double mips, int pesNumber, int ram, long bw, long size, int priority, String vmm, CloudletScheduler cloudletScheduler) {
public Vm(int id, int userId, double mips, int pesNumber, int ram, long bw, long size, String vmm, CloudletScheduler cloudletScheduler) {
setId(id);
setUserId(userId);
setUid(getUid(userId, id));
......@@ -109,7 +106,6 @@ public class Vm {
setRam(ram);
setBw(bw);
setSize(size);
setPriority(priority);
setVmm(vmm);
setCloudletScheduler(cloudletScheduler);
......@@ -396,34 +392,6 @@ public class Vm {
this.size = size;
}
/**
* Returns the priority assigned to the VM.
* Effect of the priority in the scheduling
* is policy dependent
*
* @return VM priority
*
* @pre $none
* @post $none
*/
public int getPriority() {
return this.priority;
}
/**
* Sets the priority assigned to the VM.
* Effect of the priority in the scheduling
* is policy dependent
*
* @param priority new priority assigned to the VM
*
* @pre priority >= 0
* @post $none
*/
public void setPriority(int priority) {
this.priority = priority;
}
/**
* Gets the VMM.
*
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* VmmAllocationPolicyTimeSpaceShared is a VMM allocation policy that
* allocates one or more Pe to a VM, and doesn't allow sharing
* of PEs. If there is no free PEs to the VM, allocation fails
* However, if there is free PEs, they are scheduled to the VMs
* This policy ignores requested number of MIPS.
*
* @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0
*/
public class VmSchedulerOportunisticSpaceShared extends VmScheduler {
protected Map<String,Integer> peAllocationMap;
protected int pesInUse;
public VmSchedulerOportunisticSpaceShared(List<? extends Pe> pelist) {
super(pelist);
this.pesInUse=0;
this.peAllocationMap = new HashMap<String,Integer>();
}
@Override
public boolean allocatePesForVm(Vm vm, List<Double> mipsShare){
//if there is no freePes, fails
if(vm.getPesNumber()>super.getPeList().size()) {
return false;
}
peAllocationMap.put(vm.getUid(),vm.getPesNumber());
pesInUse+=vm.getPesNumber();
return true;
}
@Override
public void deallocatePesForVm(Vm vm){
int pes = peAllocationMap.remove(vm.getUid());
pesInUse-=pes;
}
@Override
public List<Double> getAllocatedMipsForVm(Vm vm) {
double[] myShare = new double[super.getPeList().size()];
for(int i=0;i<myShare.length;i++) {
myShare[i]=0.0;
}
double capacity=0.0;
for (int i=0;i<super.getPeList().size();i++){
capacity+=super.getPeList().get(i).getMips();
}
//it receives the capacity of the allocated VMs and the capacity of the free PEs.
if(pesInUse>super.getPeList().size()){
capacity/=pesInUse;
} else {
capacity/=super.getPeList().size();
}
int pes = peAllocationMap.get(vm.getUid());
for(int i=0;i<pes;i++){
myShare[i]=capacity;
}
LinkedList<Double> outputVector = new LinkedList<Double>();
for(double share: myShare) {
outputVector.add(share);
}
return outputVector;
}
/**
* Gets the sum of available MIPS in all PEs.
*
* @return total available mips
*
* @pre $none
* @post $none
*/
@Override
public double getAvailableMips() {
if (getPeList() == null) {
Log.printLine("Pe list is empty");
return 0;
}
double mips = 0.0;
for (Pe pe : getPeList()) {
mips += pe.getPeProvisioner().getAvailableMips();
}
return mips;
}
}
......@@ -10,7 +10,7 @@ package org.cloudbus.cloudsim;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -27,10 +27,10 @@ import java.util.Map;
public class VmSchedulerSpaceShared extends VmScheduler {
/** Map containing VM ID and a vector of PEs allocated to this VM. */
private Map<String, List<Integer>> peAllocationMap;
private Map<String, List<Pe>> peAllocationMap;
/** The free pes vector. */
private List<Integer> freePes;
private List<Pe> freePes;
/**
* Instantiates a new vm scheduler space shared.
......@@ -39,19 +39,13 @@ public class VmSchedulerSpaceShared extends VmScheduler {
*/
public VmSchedulerSpaceShared(List<? extends Pe> pelist) {
super(pelist);
setPeAllocationMap(new HashMap<String, List<Integer>>());
setFreePes(new ArrayList<Integer>());
for (int i = 0; i < pelist.size(); i++) {
getFreePes().add(i);
}
setPeAllocationMap(new HashMap<String, List<Pe>>());
getFreePes().addAll(pelist);
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.VmScheduler#allocatePesForVm(org.cloudbus.cloudsim.Vm, java.util.List)
*/
/**
* TODO: rewrite using PeProvisioner
*/
@Override
public boolean allocatePesForVm(Vm vm, List<Double> mipsShare) {
//if there is no enough free PEs, fails
......@@ -59,56 +53,45 @@ public class VmSchedulerSpaceShared extends VmScheduler {
return false;
}
double currentFreeMips = getAvailableMips();
List<Integer> chosenPes = new ArrayList<Integer>();
List<Double> newMipsList = new LinkedList<Double>();
for (int i = 0; i < mipsShare.size(); i++) {
int allocatedPe = getFreePes().remove(0);
chosenPes.add(allocatedPe);
//add the smaller between requested MIPS and available MIPS: if PE supplied more capacity than requested,
//we reduce use of processor (and power consumption). Otherwise, we go PE's full power.
if (getPeList().get(allocatedPe).getMips() < mipsShare.get(i)) {
newMipsList.add((double) getPeList().get(allocatedPe).getMips());
currentFreeMips -= getPeList().get(allocatedPe).getMips();
} else {
newMipsList.add(mipsShare.get(i));
currentFreeMips -= mipsShare.get(i);
List<Pe> selectedPes = new ArrayList<Pe>();
Iterator<Pe> peIterator = getFreePes().iterator();
Pe pe = peIterator.next();
double totalMips = 0;
for (Double mips : mipsShare) {
if (mips <= pe.getMips()) {
selectedPes.add(pe);
pe = peIterator.next();
totalMips += mips;
}
}
if (mipsShare.size() > selectedPes.size()) {
return false;
}
getFreePes().removeAll(selectedPes);
getPeAllocationMap().put(vm.getUid(), chosenPes);
getMipsMap().put(vm.getUid(), newMipsList);
setAvailableMips(currentFreeMips);
getPeAllocationMap().put(vm.getUid(), selectedPes);
getMipsMap().put(vm.getUid(), mipsShare);
setAvailableMips(getAvailableMips() - totalMips);
return true;
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.VmScheduler#deallocatePesForVm(org.cloudbus.cloudsim.Vm)
*/
@Override
public void deallocatePesForVm(Vm vm) {
// free Pes
List<Integer> peVector = getPeAllocationMap().remove(vm.getUid());
if (peVector == null) {
Log.printLine(this.getClass() + ":[Error]: no Pes allocated for this VM.");
return;
}
getFreePes().addAll(getPeAllocationMap().get(vm.getUid()));
getPeAllocationMap().remove(vm.getUid());
while (!peVector.isEmpty()) {
Integer element = peVector.remove(0);
getFreePes().add(element);
}
// update use of mips
double currentMips = getAvailableMips();
double totalMips = 0;
for (double mips : getMipsMap().get(vm.getUid())) {
currentMips += mips;
totalMips += mips;
}
setAvailableMips(currentMips);
setAvailableMips(getAvailableMips() + totalMips);
getMipsMap().remove(vm.getUid());
}
/**
......@@ -116,7 +99,7 @@ public class VmSchedulerSpaceShared extends VmScheduler {
*
* @param peAllocationMap the pe allocation map
*/
protected void setPeAllocationMap(Map<String, List<Integer>> peAllocationMap) {
protected void setPeAllocationMap(Map<String, List<Pe>> peAllocationMap) {
this.peAllocationMap = peAllocationMap;
}
......@@ -125,7 +108,7 @@ public class VmSchedulerSpaceShared extends VmScheduler {
*
* @return the pe allocation map
*/
protected Map<String, List<Integer>> getPeAllocationMap() {
protected Map<String, List<Pe>> getPeAllocationMap() {
return peAllocationMap;
}
......@@ -134,7 +117,7 @@ public class VmSchedulerSpaceShared extends VmScheduler {
*
* @param freePes the new free pes vector
*/
protected void setFreePes(List<Integer> freePes) {
protected void setFreePes(List<Pe> freePes) {
this.freePes = freePes;
}
......@@ -143,7 +126,7 @@ public class VmSchedulerSpaceShared extends VmScheduler {
*
* @return the free pes vector
*/
protected List<Integer> getFreePes() {
protected List<Pe> getFreePes() {
return freePes;
}
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* VmSchedulerTimeSharedWithPriority is a VMM allocation policy that
* allows sharing of PEs among virtual machines. CPU Share of each VM can be
* set through the priority field. The smaller value accepted for priority is
* 1. Values smaller than that are set to 1. Priority means how many times
* one machine runs faster than the other. E.g.: if a VM A has priority
* 1 and a VM B has a priority 2, B will run twice as faster as A.
*
* @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0
*/
public class VmSchedulerTimeSharedWithPriority extends VmScheduler {
protected Map<String,PEShare> peAllocationMap;
protected int pesInUse;
protected int shares;
public VmSchedulerTimeSharedWithPriority(List<? extends Pe> pelist) {
super(pelist);
this.pesInUse=0;
this.shares=0;
this.peAllocationMap = new HashMap<String,PEShare>();
}
@Override
public boolean allocatePesForVm(Vm vm, List<Double> mipsShare){
int priority = vm.getPriority();
if(priority<1) {
priority=1;
}
peAllocationMap.put(vm.getUid(),new PEShare(vm.getPesNumber(),priority));
pesInUse+=vm.getPesNumber();
shares+=priority;
return true;
}
@Override
public void deallocatePesForVm(Vm vm){
PEShare peShare = peAllocationMap.remove(vm.getUid());
pesInUse-=peShare.getPes();
shares-=peShare.getShare();
}
/**
* Returns the MIPS share of each Pe that is available to a given VM
* @param id ID of the VM
* @param userId ID of VM's owner
* @return an array containing the amount of MIPS of each pe that is available to the VM
* @pre $none
* @post $none
*/
@Override
public List<Double> getAllocatedMipsForVm(Vm vm) {
//divides available MIPS among all VMs
List<Double> myShare = new LinkedList<Double>();
for(int i=0;i<getPeList().size();i++) {
myShare.add(0.0);
}
double capacity=0.0;
for (int i=0;i<getPeList().size();i++){
capacity+=getPeList().get(i).getMips();
if(i+1==pesInUse) {
break;
}
}
capacity/=shares;
PEShare peShare = this.peAllocationMap.get(vm.getUid());
int pes = peShare.getPes();
int share = peShare.getShare();
for(int i=0;i<pes;i++){
myShare.remove(i);
myShare.add(i, capacity*share/pes);
}
return myShare;
}
/**
* Gets the sum of available MIPS in all PEs.
*
* @return total available mips
*
* @pre $none
* @post $none
*/
@Override
public double getAvailableMips() {
if (getPeList() == null) {
Log.printLine("Pe list is empty");
return 0;
}
double mips = 0.0;
for (Pe pe : getPeList()) {
mips += pe.getPeProvisioner().getAvailableMips();
}
return mips;
}
/**
* Internal class to store the PEs and the share of each VM.
*
*/
static class PEShare{
private final int pes;
private final int share;
PEShare(int pes, int share){
this.pes = pes;
this.share = share;
}
public int getPes() {
return pes;
}
public int getShare() {
return share;
}
}
}
......@@ -81,11 +81,6 @@ public class PowerDatacenter extends Datacenter {
*/
@Override
protected void updateCloudletProcessing() {
// if (isInMigration()) {
// CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
// schedule(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
// return;
// }
if (getCloudletSubmitted() == -1 || getCloudletSubmitted() == CloudSim.clock()) {
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.VM_DATACENTER_EVENT));
schedule(getId(), getSchedulingInterval(), CloudSimTags.VM_DATACENTER_EVENT);
......@@ -158,15 +153,10 @@ public class PowerDatacenter extends Datacenter {
targetHost.addMigratingInVm(vm);
if (targetHost.getVmList().size() + targetHost.getVmsMigratingIn().size() > 16) {
Log.printLine("problem");
}
if (oldHost == null) {
Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId());
} else {
Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId());
//oldHost.vmDestroy(vm);
}
incrementMigrationCount();
......
......@@ -78,8 +78,8 @@ public class HostDynamicWorkloadTest {
@Test
public void testGetMaxUtilization() {
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
assertTrue(peList.get(0).getPeProvisioner().allocateMipsForVm(vm0, MIPS / 3));
assertTrue(peList.get(1).getPeProvisioner().allocateMipsForVm(vm1, MIPS / 5));
......@@ -89,8 +89,8 @@ public class HostDynamicWorkloadTest {
@Test
public void testGetMaxUtilizationAmongVmsPes() {
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
assertTrue(peList.get(0).getPeProvisioner().allocateMipsForVm(vm0, MIPS / 3));
assertTrue(peList.get(1).getPeProvisioner().allocateMipsForVm(vm1, MIPS / 5));
......
......@@ -68,8 +68,8 @@ public class HostTest {
@Test
public void testIsSuitableForVm() {
Vm vm0 = new Vm(0, 0, MIPS, 2, RAM, BW, 0, 0, "", new CloudletSchedulerSingleService(MIPS, 2));
Vm vm1 = new Vm(1, 0, MIPS * 2, 1, RAM * 2, BW * 2, 0, 0, "", new CloudletSchedulerSingleService(MIPS * 2, 2));
Vm vm0 = new Vm(0, 0, MIPS, 2, RAM, BW, 0, "", new CloudletSchedulerSingleService(MIPS, 2));
Vm vm1 = new Vm(1, 0, MIPS * 2, 1, RAM * 2, BW * 2, 0, "", new CloudletSchedulerSingleService(MIPS * 2, 2));
assertTrue(host.isSuitableForVm(vm0));
assertFalse(host.isSuitableForVm(vm1));
......@@ -77,10 +77,10 @@ public class HostTest {
@Test
public void testVmCreate() {
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, RAM / 2, BW / 2, 0, 0, "", new CloudletSchedulerSingleService(MIPS / 2, 1));
Vm vm1 = new Vm(1, 0, MIPS, 1, RAM, BW, 0, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
Vm vm2 = new Vm(2, 0, MIPS * 2, 1, RAM, BW, 0, 0, "", new CloudletSchedulerSingleService(MIPS * 2, 1));
Vm vm3 = new Vm(3, 0, MIPS / 2, 2, RAM / 2, BW / 2, 0, 0, "", new CloudletSchedulerSingleService(MIPS / 2, 2));
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, RAM / 2, BW / 2, 0, "", new CloudletSchedulerSingleService(MIPS / 2, 1));
Vm vm1 = new Vm(1, 0, MIPS, 1, RAM, BW, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
Vm vm2 = new Vm(2, 0, MIPS * 2, 1, RAM, BW, 0, "", new CloudletSchedulerSingleService(MIPS * 2, 1));
Vm vm3 = new Vm(3, 0, MIPS / 2, 2, RAM / 2, BW / 2, 0, "", new CloudletSchedulerSingleService(MIPS / 2, 2));
assertTrue(host.vmCreate(vm0));
assertFalse(host.vmCreate(vm1));
......@@ -90,7 +90,7 @@ public class HostTest {
@Test
public void testVmDestroy() {
Vm vm = new Vm(0, 0, MIPS, 1, RAM / 2, BW / 2, 0, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
Vm vm = new Vm(0, 0, MIPS, 1, RAM / 2, BW / 2, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
assertTrue(host.vmCreate(vm));
assertSame(vm, host.getVm(0, 0));
......@@ -104,8 +104,8 @@ public class HostTest {
@Test
public void testVmDestroyAll() {
Vm vm0 = new Vm(0, 0, MIPS, 1, RAM / 2, BW / 2, 0, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
Vm vm1 = new Vm(1, 0, MIPS, 1, RAM / 2, BW / 2, 0, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
Vm vm0 = new Vm(0, 0, MIPS, 1, RAM / 2, BW / 2, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
Vm vm1 = new Vm(1, 0, MIPS, 1, RAM / 2, BW / 2, 0, "", new CloudletSchedulerSingleService(MIPS, 1));
assertTrue(host.vmCreate(vm0));
assertSame(vm0, host.getVm(0, 0));
......
......@@ -40,8 +40,8 @@ public class VmSchedulerTimeSharedTest {
peList.add(new Pe(0, new PeProvisionerSimple(MIPS)));
peList.add(new Pe(1, new PeProvisionerSimple(MIPS)));
vmScheduler = new VmSchedulerTimeShared(peList);
vm1 = new Vm(0, 0, MIPS / 4, 1, 0, 0, 0, 0, "", null);
vm2 = new Vm(1, 0, MIPS / 2, 2, 0, 0, 0, 0, "", null);
vm1 = new Vm(0, 0, MIPS / 4, 1, 0, 0, 0, "", null);
vm2 = new Vm(1, 0, MIPS / 2, 2, 0, 0, 0, "", null);
//vm3 = new Vm(2, 0, MIPS, 2, 0, 0, 0, 0, "", null);
}
......@@ -144,10 +144,10 @@ public class VmSchedulerTimeSharedTest {
List<Pe> peList = new ArrayList<Pe>();
peList.add(new Pe(0, new PeProvisionerSimple(3500)));
VmScheduler vmScheduler = new VmSchedulerTimeShared(peList);
Vm vm1 = new Vm(0, 0, 170, 1, 0, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 2000, 1, 0, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, 10, 1, 0, 0, 0, 0, "", null);
Vm vm4 = new Vm(3, 0, 2000, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 170, 1, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 2000, 1, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, 10, 1, 0, 0, 0, "", null);
Vm vm4 = new Vm(3, 0, 2000, 1, 0, 0, 0, "", null);
List<Double> mipsShare1 = new ArrayList<Double>();
mipsShare1.add(170.0);
......
......@@ -36,7 +36,6 @@ public class VmTest {
private static final int RAM = 1024;
private static final int BW = 10000;
private static final long SIZE = 1000;
private static final int PRIORITY = 1;
private static final String VMM = "Xen";
private CloudletSchedulerSingleService vmScheduler;
......@@ -45,7 +44,7 @@ public class VmTest {
@Before
public void setUp() throws Exception {
vmScheduler = new CloudletSchedulerSingleService(MIPS, PES_NUMBER);
vm = new Vm(ID, USER_ID, MIPS, PES_NUMBER, RAM, BW, SIZE, PRIORITY, VMM, vmScheduler);
vm = new Vm(ID, USER_ID, MIPS, PES_NUMBER, RAM, BW, SIZE, VMM, vmScheduler);
}
@Test
......@@ -79,11 +78,6 @@ public class VmTest {
assertEquals(SIZE, vm.getSize());
}
@Test
public void testGetPriority() {
assertEquals(PRIORITY, vm.getPriority());
}
@Test
public void testGetVmm() {
assertEquals(VMM, vm.getVmm());
......@@ -168,7 +162,7 @@ public class VmTest {
@Test
public void testGetCurrentRequestedMips() {
CloudletScheduler cloudletScheduler = createMock(CloudletScheduler.class);
Vm vm = new Vm(ID, USER_ID, MIPS, PES_NUMBER, RAM, BW, SIZE, PRIORITY, VMM, cloudletScheduler);
Vm vm = new Vm(ID, USER_ID, MIPS, PES_NUMBER, RAM, BW, SIZE, VMM, cloudletScheduler);
List<Double> expectedCurrentMips1 = new ArrayList<Double>();
expectedCurrentMips1.add(MIPS);
......@@ -196,7 +190,7 @@ public class VmTest {
@Test
public void testGetCurrentRequestedTotalMips() {
CloudletScheduler cloudletScheduler = createMock(CloudletScheduler.class);
Vm vm = new Vm(ID, USER_ID, MIPS, PES_NUMBER, RAM, BW, SIZE, PRIORITY, VMM, cloudletScheduler);
Vm vm = new Vm(ID, USER_ID, MIPS, PES_NUMBER, RAM, BW, SIZE, VMM, cloudletScheduler);
ArrayList<Double> currentMips = new ArrayList<Double>();
currentMips.add(MIPS);
......
......@@ -100,8 +100,8 @@ public class PeListTest {
@Test
public void testGetMaxUtilization() {
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
assertTrue(peList.get(0).getPeProvisioner().allocateMipsForVm(vm0, MIPS / 3));
assertTrue(peList.get(1).getPeProvisioner().allocateMipsForVm(vm1, MIPS / 5));
......@@ -111,8 +111,8 @@ public class PeListTest {
@Test
public void testGetMaxUtilizationAmongVmsPes() {
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
assertTrue(peList.get(0).getPeProvisioner().allocateMipsForVm(vm0, MIPS / 3));
assertTrue(peList.get(1).getPeProvisioner().allocateMipsForVm(vm1, MIPS / 5));
......
......@@ -37,9 +37,9 @@ public class VmListTest {
assertNull(VmList.getById(vmList, 1));
assertNull(VmList.getById(vmList, 2));
Vm vm1 = new Vm(0, 0, 0, 1, 0, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 1, 0, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, 0, 2, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 1, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 1, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, 0, 2, 0, 0, 0, "", null);
vmList.add(vm1);
vmList.add(vm2);
......@@ -57,10 +57,10 @@ public class VmListTest {
assertNull(VmList.getByIdAndUserId(vmList, 0, 1));
assertNull(VmList.getByIdAndUserId(vmList, 1, 1));
Vm vm1 = new Vm(0, 0, 0, 1, 0, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 1, 0, 0, 0, 0, "", null);
Vm vm3 = new Vm(0, 1, 0, 2, 0, 0, 0, 0, "", null);
Vm vm4 = new Vm(1, 1, 0, 2, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 1, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 1, 0, 0, 0, "", null);
Vm vm3 = new Vm(0, 1, 0, 2, 0, 0, 0, "", null);
Vm vm4 = new Vm(1, 1, 0, 2, 0, 0, 0, "", null);
vmList.add(vm1);
vmList.add(vm2);
......
......@@ -50,8 +50,8 @@ public class PeListTest {
@Test
public void testGetPower() throws Exception {
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm0 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm1 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
assertTrue(peList.get(0).getPeProvisioner().allocateMipsForVm(vm0, MIPS / 3));
assertTrue(peList.get(1).getPeProvisioner().allocateMipsForVm(vm1, MIPS / 5));
......
......@@ -43,8 +43,8 @@ public class BwProvisionerSimpleTest {
@Test
public void testAllocateBwforVm() {
Vm vm1 = new Vm(0, 0, 0, 0, 0, BW / 2, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, 0, BW, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 0, 0, BW / 2, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, 0, BW, 0, "", null);
assertTrue(bwProvisioner.isSuitableForVm(vm1, BW / 2));
assertTrue(bwProvisioner.allocateBwForVm(vm1, BW / 2));
......@@ -65,8 +65,8 @@ public class BwProvisionerSimpleTest {
@Test
public void testGetAllocatedBwforVm() {
Vm vm1 = new Vm(0, 0, 0, 0, 0, BW / 2, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, 0, BW, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 0, 0, BW / 2, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, 0, BW, 0, "", null);
assertTrue(bwProvisioner.isSuitableForVm(vm1, BW / 2));
assertTrue(bwProvisioner.allocateBwForVm(vm1, BW / 2));
......@@ -87,8 +87,8 @@ public class BwProvisionerSimpleTest {
@Test
public void testDeallocateBwForVm() {
Vm vm1 = new Vm(0, 0, 0, 0, 0, BW / 2, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, 0, BW / 2, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 0, 0, BW / 2, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, 0, BW / 2, 0, "", null);
assertEquals(0, vm1.getCurrentAllocatedBw());
assertEquals(0, vm2.getCurrentAllocatedBw());
......
......@@ -56,9 +56,9 @@ public class PeProvisionerSimpleTest {
@Test
public void testAllocateMipsForVm() {
Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, MIPS / 2, 2, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, MIPS / 2, 2, 0, 0, 0, "", null);
assertTrue(peProvisioner.allocateMipsForVm(vm1, MIPS / 2));
assertEquals(MIPS / 2, peProvisioner.getAvailableMips(), 0);
......@@ -100,9 +100,9 @@ public class PeProvisionerSimpleTest {
@Test
public void testGetAllocatedMipsForVm() {
Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, MIPS / 2, 2, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm3 = new Vm(2, 0, MIPS / 2, 2, 0, 0, 0, "", null);
assertNull(peProvisioner.getAllocatedMipsForVm(vm1));
assertEquals(0, peProvisioner.getAllocatedMipsForVmByVirtualPeId(vm1, 0), 0);
......@@ -175,8 +175,8 @@ public class PeProvisionerSimpleTest {
@Test
public void testDeallocateMipsForVM() {
Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, MIPS / 2, 1, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, MIPS / 2, 1, 0, 0, 0, "", null);
peProvisioner.allocateMipsForVm(vm1, MIPS / 2);
peProvisioner.allocateMipsForVm(vm2, MIPS / 4);
......
......@@ -43,8 +43,8 @@ public class RamProvisionerSimpleTest {
@Test
public void testAllocateRamForVm() {
Vm vm1 = new Vm(0, 0, 0, 0, RAM / 2, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, RAM, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 0, RAM / 2, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, RAM, 0, 0, "", null);
assertTrue(ramProvisioner.isSuitableForVm(vm1, RAM / 2));
assertTrue(ramProvisioner.allocateRamForVm(vm1, RAM / 2));
......@@ -65,8 +65,8 @@ public class RamProvisionerSimpleTest {
@Test
public void testGetAllocatedRamForVm() {
Vm vm1 = new Vm(0, 0, 0, 0, RAM / 2, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, RAM, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 0, RAM / 2, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, RAM, 0, 0, "", null);
assertTrue(ramProvisioner.isSuitableForVm(vm1, RAM / 2));
assertTrue(ramProvisioner.allocateRamForVm(vm1, RAM / 2));
......@@ -87,8 +87,8 @@ public class RamProvisionerSimpleTest {
@Test
public void testDeallocateBwForVm() {
Vm vm1 = new Vm(0, 0, 0, 0, RAM / 2, 0, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, RAM / 2, 0, 0, 0, "", null);
Vm vm1 = new Vm(0, 0, 0, 0, RAM / 2, 0, 0, "", null);
Vm vm2 = new Vm(1, 0, 0, 0, RAM / 2, 0, 0, "", null);
assertEquals(0, vm1.getCurrentAllocatedRam());
assertEquals(0, vm2.getCurrentAllocatedRam());
......
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