Skip to content

Commit

Permalink
Closes #156
Browse files Browse the repository at this point in the history
Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
  • Loading branch information
manoelcampos committed Oct 3, 2018
1 parent 80d27ac commit cff73f4
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cloudsim-plus-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus-benchmarks</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<name>CloudSim Plus Benchmarks</name>
<description>A module containing benchmarks created using JMH (Java Microbenchmark Harness framework) to assess CloudSim Plus performance</description>
<url>http://cloudsimplus.org</url>
Expand Down
2 changes: 1 addition & 1 deletion cloudsim-plus-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus-examples</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<name>CloudSim Plus Examples</name>
<description>
Ready-to-run examples of how to use CloudSim Plus API.
Expand Down
2 changes: 1 addition & 1 deletion cloudsim-plus-testbeds/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus-testbeds</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<name>CloudSim Plus Testbeds</name>
<description>
A set of more complex and comprehensive CloudSim Plus testbeds used to assess
Expand Down
2 changes: 1 addition & 1 deletion cloudsim-plus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<name>CloudSim Plus API</name>
<description>CloudSim Plus: A modern, highly extensible and easier-to-use Java 8 Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services</description>
<url>http://cloudsimplus.org</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,19 @@ private void processCloudletFinish(final SimEvent evt){
if(cloudlet.getFinishedLengthSoFar() == 0){
cloudlet.getVm().getHost().updateProcessing(getSimulation().clock());
}

/* If after updating the host processing, the cloudlet executed length is still zero,
* it means the Cloudlet has never started. This happens, for instance, due
* to lack of PEs to run the Cloudlet (usually when you're using a CloudletSchedulerSpaceShared).
* This way, sets the Cloudlet as failed. */
if(cloudlet.getFinishedLengthSoFar() == 0) {
cloudlet.getVm().getCloudletScheduler().cloudletFail(cloudlet);
return;
}

cloudlet.setLength(cloudlet.getFinishedLengthSoFar());
/*After defining the Cloudlet length, updates the Cloudlet processing again so that the Cloudlet status
* is updated at this clock tick instead of the next one.*/
/* After defining the Cloudlet length, updates the Cloudlet processing again so that the Cloudlet status
* is updated at this clock tick instead of the next one.*/
cloudlet.getVm().getHost().updateProcessing(getSimulation().clock());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ enum Status {
*/
READY,

/**
* The Cloudlet has moved to a Vm but it is in the waiting queue.
*/
QUEUED,

/**
* The Cloudlet is in the waiting queue but it won't be automatically moved
* to the execution list (even if there are available PEs) until
Expand All @@ -59,11 +64,6 @@ enum Status {
*/
FROZEN,

/**
* The Cloudlet has moved to a Vm.
*/
QUEUED,

/**
* The Cloudlet is in execution in a Vm.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CloudSim implements Simulation {
/**
* CloudSim Plus current version.
*/
public static final String VERSION = "4.0.2";
public static final String VERSION = "4.0.3";

private static final Logger LOGGER = LoggerFactory.getLogger(CloudSim.class.getSimpleName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ protected double getEstimatedFinishTimeOfCloudlet(final CloudletExecution cle, f
*/
protected void moveNextCloudletsFromWaitingToExecList() {
Optional<CloudletExecution> optional = Optional.of(CloudletExecution.NULL);
while (!cloudletWaitingList.isEmpty() && optional.isPresent() && getFreePes() > 0) {
while (!cloudletWaitingList.isEmpty() && optional.isPresent()) {
optional = findSuitableWaitingCloudlet();
optional.ifPresent(this::addWaitingCloudletToExecList);
}
Expand All @@ -837,7 +837,7 @@ protected Optional<CloudletExecution> findSuitableWaitingCloudlet() {
return cloudletWaitingList
.stream()
.filter(cle -> cle.getCloudlet().getStatus() != Status.FROZEN)
.filter(this::isThereEnoughFreePesForCloudlet)
.filter(this::canExecuteCloudlet)
.findFirst();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package org.cloudsimplus.integrationtests;

import ch.qos.logback.classic.Level;
import org.cloudbus.cloudsim.brokers.DatacenterBroker;
import org.cloudbus.cloudsim.cloudlets.Cloudlet;
import org.cloudbus.cloudsim.core.CloudSim;
Expand All @@ -39,6 +40,7 @@
import org.cloudsimplus.listeners.EventListener;
import org.cloudsimplus.listeners.VmDatacenterEventInfo;
import org.cloudsimplus.listeners.VmHostEventInfo;
import org.cloudsimplus.util.Log;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
Expand All @@ -52,25 +54,25 @@
*
* An Integration Test (IT) to check a simulation scenario with 1 PM that has
* capacity to host just 1 of the user's VMs. Two cloudlets are submitted to the
* same VM and run using the SpaceShared CloudletScheduler.
* same VM and run using the CloudletSchedulerSpaceShared.
* The Integration Test performs several tests that aren't described here in
* order to avoid the documentation being out-of-date in case the IT is changed.
*
* <p>To see what verifications are being performed, take a look at methods such as
* <p>To check which verifications are being performed, take a look at methods such as
* {@link #assertThatBrokerCloudletsHaveTheExpectedExecutionTimes(DatacenterBroker)}
* and all the others that start with "assertThat". Those method names were
* defined to give an exact notion of what is being tested.</p>
*
* <p>The IT uses the new VM listeners to get notified when a host is allocated,
* deallocated for a given VM and when a VM fails to be created due to lack of
* host resources. It also relies on the new CloudSim
* host resources. It also relies on the new CloudSim Plus
* {@link CloudSim#addOnEventProcessingListener(EventListener) process event listener} to be notified every time
* when any event is processed by CloudSim. By this way, it is possible to
* verify, for instance, if the resource usage of a given host at a given time
* is as expected.</p>
*
* <i><b>NOTE</b>:See the profile section in the pom.xml for details of how to
* run all tests, including Functional/Integration Tests in this package.</i>
* <i><b>NOTE</b>:See the profile section in the pom.xml for details on how to
* run all tests, including Functional/Integration Tests.</i>
*
* @see Vm#addOnHostAllocationListener(EventListener)
* @see Vm#addOnHostDeallocationListener(EventListener)
Expand Down Expand Up @@ -186,28 +188,29 @@ private void onUpdateVmProcessing(final VmHostEventInfo evt) {

@Before
public void setUp() {
Log.setLevel(Level.WARN);
simulation = new CloudSim();
simulation.addOnEventProcessingListener((evt) -> onEventProcessing(evt));
simulation.addOnEventProcessingListener(this::onEventProcessing);
scenario = new SimulationScenarioBuilder(simulation);
scenario.getDatacenterBuilder().createDatacenter(
new HostBuilder()
.setVmSchedulerClass(VmSchedulerTimeShared.class)
.setRam(2048).setBandwidth(10000)
.setPes(1).setMips(1200)
.createOneHost()
.getHosts()
.setVmSchedulerClass(VmSchedulerTimeShared.class)
.setRam(2048).setBandwidth(10000)
.setPes(1).setMips(1200)
.createOneHost()
.getHosts()
);

final BrokerBuilderDecorator brokerBuilder = scenario.getBrokerBuilder().createBroker();

brokerBuilder.getVmBuilder()
.setRam(512).setBandwidth(1000)
.setPes(1).setMips(1000).setSize(10000)
.setCloudletSchedulerSupplier(() -> new CloudletSchedulerSpaceShared())
.setOnHostAllocationListener(evt -> onHostAllocation(evt))
.setOnHostDeallocationListener(evt -> onHostDeallocation(evt))
.setOnVmCreationFilatureListenerForAllVms(evt -> onVmCreationFailure(evt))
.setOnUpdateVmProcessingListener(evt -> onUpdateVmProcessing(evt))
.setCloudletSchedulerSupplier(CloudletSchedulerSpaceShared::new)
.setOnHostAllocationListener(this::onHostAllocation)
.setOnHostDeallocationListener(this::onHostDeallocation)
.setOnVmCreationFilatureListenerForAllVms(this::onVmCreationFailure)
.setOnUpdateVmProcessingListener(this::onUpdateVmProcessing)
/*try to create 2 VMs where there is capacity to only one,
thus, 1 will fail being created*/
.createAndSubmitVms(2);
Expand Down Expand Up @@ -242,9 +245,7 @@ public void assertThatBrokerCloudletsHaveTheExpectedExecutionTimes(DatacenterBro
};

final List<Cloudlet> cloudletList = broker.getCloudletFinishedList();
assertEquals(
"The number of finished cloudlets was not as expected",
cloudletList.size(), expectedResults.length);
assertEquals("The number of finished cloudlets was not as expected", expectedResults.length, cloudletList.size());
int i = -1;
for (final Cloudlet cloudlet : cloudletList) {
expectedResults[++i].setCloudlet(cloudlet);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.cloudsimplus</groupId>
<artifactId>cloudsim-plus-package</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<packaging>pom</packaging>

<name>CloudSim Plus Modules (All)</name>
Expand Down

0 comments on commit cff73f4

Please sign in to comment.