Commit 887a7ae9 authored by Eduardo Falcão's avatar Eduardo Falcão
Browse files

fixing integration test

parent f86e954b
......@@ -292,7 +292,7 @@ public abstract class CloudletAbstract implements Cloudlet {
@Override
public final Cloudlet setLength(final long length) {
if (length < 0) {
if (length <= 0) {
throw new IllegalArgumentException("Cloudlet length has to be greater than zero.");
}
......
......@@ -410,8 +410,8 @@ public class DatacenterSimple extends CloudSimEntity implements Datacenter {
}
final List<Double> mipsList = vm.getHost().getVmScheduler().getAllocatedMips(vm);
//final double iops = vm.getHost().getVmScheduler().getAllocatedIops(vm);
final double iops = vm.getIops().getAllocatedResource();
final double iops = vm.getHost().getVmScheduler().getAllocatedIops(vm);
// final double iops = vm.getIops().getAllocatedResource();
System.out.println("Teste1! Vm id="+vm.getId()+", iops="+iops);
vm.updateProcessing(getSimulation().clock(), mipsList, iops);
}
......
......@@ -242,7 +242,6 @@ public class HostSimple implements Host {
* e.g., in cases when Vm is destroyed during simulation execution.*/
for (int i = 0; i < vmList.size(); i++) {
final Vm vm = vmList.get(i);
//System.out.println("Teste1.2! Host id="+id+", vmId="+vm.getId()+", iops="+iops);
final double nextTime = vm.updateProcessing(currentTime, vmScheduler.getAllocatedMips(vm), vmScheduler.getAllocatedIops(vm));
nextSimulationTime = Math.min(nextTime, nextSimulationTime);
}
......
......@@ -53,8 +53,6 @@ public class ResourceProvisionerShared extends ResourceProvisionerAbstract {
@Override
public boolean allocateResourceForVm(final Vm vm, final long newTotalVmResourceCapacity) {
System.out.println("vm id = "+vm.getId()+"; resource: "+getResourceClass().getCanonicalName());
Objects.requireNonNull(vm);
if (!isSuitableForVm(vm, newTotalVmResourceCapacity)) {
return false;
......@@ -120,12 +118,13 @@ public class ResourceProvisionerShared extends ResourceProvisionerAbstract {
class VmRequestedAllocated implements Comparable<VmRequestedAllocated>{
private Vm vm;
private Long requested, newCapacity;
private Long prevAllocated, requested, newCapacity;
public VmRequestedAllocated(Vm vm, Long requested, Long newCapacity) {
super();
this.vm = vm;
this.requested = requested;
this.prevAllocated = requested;
this.newCapacity = newCapacity;
}
......@@ -175,6 +174,10 @@ public class ResourceProvisionerShared extends ResourceProvisionerAbstract {
public void addNewCapacity(Long extraCapacity) {
this.newCapacity += extraCapacity;
}
public Long getPrevAllocated() {
return prevAllocated;
}
}
......@@ -237,14 +240,8 @@ public class ResourceProvisionerShared extends ResourceProvisionerAbstract {
it = vmRequestedAndAllocatedList.listIterator(); //update iterator with new state of the list
}
for(VmRequestedAllocated vra : finalList){
//Allocates the requested resource from the physical resource
final long prevVmResourceAllocation = vra.getVm().getResource(getResourceClass()).getAllocatedResource();
if (getResourceAllocationMap().containsKey(vra.getVm())) {
//Deallocates any amount of the resource assigned to the Vm in order to allocate a new capacity
deallocateResourceForVm(vra.getVm());
}
deallocateResourceForAllVms();
for(VmRequestedAllocated vra : finalList){
/*
Pe resources are not stored in the VM resource List.
Only the provisioner keeps track of Pe allocation for VM.
......@@ -258,10 +255,9 @@ public class ResourceProvisionerShared extends ResourceProvisionerAbstract {
//Allocates the requested resource from the physical resource
getResource().allocateResource(vra.getNewCapacity());
getResourceAllocationMap().put(vra.getVm(), vra.getNewCapacity());
vra.getVm().getResource(getResourceClass()).setAllocatedResource(prevVmResourceAllocation);
}
long newAllocated = Math.min(vra.getPrevAllocated(), vra.getNewCapacity());
vra.getVm().getResource(getResourceClass()).setAllocatedResource(newAllocated);
}
}
......
......@@ -712,9 +712,10 @@ public abstract class CloudletSchedulerAbstract implements CloudletScheduler {
* to be acquired from the Datacenter storage.
*/
final double actualProcessingTime = (hasCloudletFileTransferTimePassed(cl, currentTime) ? timeSpan(cl, currentTime) : 0);
double availableIops = getAvailableIops(cl);
final double cloudletUsedIops =
getAbsoluteCloudletResourceUtilization(cl.getCloudlet().getUtilizationModelIops(),
currentTime, getAvailableIops(cl));
currentTime, availableIops);
return (long) (cloudletUsedIops * actualProcessingTime);
}
......
......@@ -233,8 +233,6 @@ public class VmSimple implements Vm {
public double updateProcessing(final double currentTime, final List<Double> mipsShare, double iops) {
Objects.requireNonNull(mipsShare);
//System.out.println("Teste2! Vm id="+id+", iops="+iops);
if(!cloudletScheduler.getCloudletExecList().isEmpty()){
this.lastBuzyTime = getSimulation().clock();
}
......
......@@ -44,6 +44,7 @@ import org.cloudsimplus.listeners.EventListener;
*/
public class CloudletBuilder extends Builder {
private long length = 10000;
private long iopsLength = 10000;
private long outputSize = 300;
private long fileSize = 300;
private int pes = 1;
......@@ -144,6 +145,12 @@ public class CloudletBuilder extends Builder {
this.length = defaultLength;
return this;
}
public CloudletBuilder setIopsLength(long defaultLength) {
this.iopsLength = defaultLength;
return this;
}
public CloudletBuilder createCloudlets(final int amount, final int initialId) {
createCloudletsInternal(amount, initialId);
return this;
......@@ -174,6 +181,7 @@ public class CloudletBuilder extends Builder {
final int cloudletId = initialId + createdCloudlets++;
final Cloudlet cloudlet =
new CloudletSimple(cloudletId, length, pes)
.setIops(iopsLength)
.setFileSize(fileSize)
.setOutputSize(outputSize)
.setUtilizationModelCpu(utilizationModelCpu)
......
......@@ -321,25 +321,27 @@ public class CloudletSimpleTest {
}
private static CloudletSimple createCloudlet(
final int id, UtilizationModel cpuRamAndBwUtilizationModel) {
return createCloudlet(id, cpuRamAndBwUtilizationModel,
cpuRamAndBwUtilizationModel,
cpuRamAndBwUtilizationModel);
final int id, UtilizationModel cpuRamBwAndIopsUtilizationModel) {
return createCloudlet(id, cpuRamBwAndIopsUtilizationModel,
cpuRamBwAndIopsUtilizationModel,
cpuRamBwAndIopsUtilizationModel,
cpuRamBwAndIopsUtilizationModel);
}
public static CloudletSimple createCloudlet(
final int id, long length, int numberOfPes) {
final UtilizationModel um = new UtilizationModelFull();
return createCloudlet(id, um, um, um, length, numberOfPes);
return createCloudlet(id, um, um, um, um, length, numberOfPes);
}
private static CloudletSimple createCloudlet(final int id,
UtilizationModel utilizationModelCPU,
UtilizationModel utilizationModelRAM,
UtilizationModel utilizationModelBW)
UtilizationModel utilizationModelBW,
UtilizationModel utilizationModelIOPS)
{
return createCloudlet(
id, utilizationModelCPU, utilizationModelRAM, utilizationModelBW,
id, utilizationModelCPU, utilizationModelRAM, utilizationModelBW, utilizationModelIOPS,
CLOUDLET_LENGTH, 1);
}
......@@ -351,6 +353,7 @@ public class CloudletSimpleTest {
UtilizationModel utilizationModelCPU,
UtilizationModel utilizationModelRAM,
UtilizationModel utilizationModelBW,
UtilizationModel utilizationModelIOPS,
long length, int numberOfPes)
{
final CloudletSimple cloudlet = new CloudletSimple(id, length, numberOfPes);
......@@ -363,7 +366,9 @@ public class CloudletSimpleTest {
.setOutputSize(CLOUDLET_OUTPUT_SIZE)
.setUtilizationModelCpu(utilizationModelCPU)
.setUtilizationModelRam(utilizationModelRAM)
.setUtilizationModelBw(utilizationModelBW);
.setUtilizationModelBw(utilizationModelBW)
.setUtilizationModelIops(utilizationModelIOPS)
.setIops(length);
cloudlet.setBroker(Mocks.createMockBroker(cloudsim));
return cloudlet;
}
......@@ -477,6 +482,7 @@ public class CloudletSimpleTest {
assertFalse(c.isFinished());
c.setFinishedLengthSoFar(length);
c.setFinishedIopsSoFar(length);
assertTrue(c.isFinished());
}
......
......@@ -93,7 +93,7 @@ public final class CheckCloudletStartDelayForTransferRequiredFilesTest {
.createDatacenter(
new HostBuilder()
.setVmSchedulerClass(VmSchedulerSpaceShared.class)
.setRam(4000).setBw(400000)
.setRam(4000).setBw(400000).setIops(10000)
.setPes(HOST_PES).setMips(HOST_MIPS)
.createOneHost()
.getHosts()
......@@ -102,18 +102,19 @@ public final class CheckCloudletStartDelayForTransferRequiredFilesTest {
final BrokerBuilderDecorator brokerBuilder = scenario.getBrokerBuilder().createBroker();
this.broker = brokerBuilder.getBroker();
brokerBuilder.getVmBuilder()
.setRam(1000).setBw(100000)
brokerBuilder.getVmBuilder() //FIXME seems to be on cloudletSchedulerAbstract (where in the code the scheduler allocates IOPS from VM???)
.setRam(1000).setBw(100000).setIops(10000) //FIXME it works with 5000, but we must check why it fails for 10000 (once provisioner is shared)
.setPes(VM_PES).setMips(VM_MIPS).setSize(50000)
.setCloudletSchedulerSupplier(CloudletSchedulerSpaceShared::new)
.createAndSubmitOneVm();
brokerBuilder.getVmBuilder()
.setCloudletSchedulerSupplier(CloudletSchedulerTimeShared::new)
.setCloudletSchedulerSupplier(CloudletSchedulerSpaceShared::new)
.createAndSubmitOneVm();
brokerBuilder.getCloudletBuilder()
.setLength(CLOUDLET_LENGTH)
.setIopsLength(1)
.setUtilizationModelCpu(new UtilizationModelFull())
.setPEs(CLOUDLET_PES)
.setRequiredFiles(getFileNames())
......
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