Skip to content

Commit

Permalink
Updates documentation.
Browse files Browse the repository at this point in the history
Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
  • Loading branch information
manoelcampos committed Nov 5, 2018
1 parent ac40845 commit 5b42f48
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,29 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import java.util.function.Function;

import static java.util.Comparator.comparingDouble;
import static java.util.Comparator.comparingLong;
import static java.util.stream.Collectors.toList;
import static org.cloudsimplus.testbeds.sla.taskcompletiontime.CloudletTaskCompletionTimeMinimizationRunner.*;

/**
* An experiment that tries to minimize task completion time,
* where workload imposed by Cloudlets is defined randomly.
* An experiment that tries to minimize task completion time
* by selecting as the VM to run a Cloudlet,
* that one that minimizes the Cloudlet completion time.
*
* <p>
* It uses the {@link DatacenterBroker#setVmMapper(Function)}
* method to define the policy used to map Cloudlets to VMs.
* The workload is defined as a set of randomly created Cloudlets.
* </p>
*
* <p>For more details, check
* <a href="http://www.di.ubi.pt/~mario/files/MScDissertation-RaysaOliveira.pdf">Raysa Oliveira's Master Thesis (only in Portuguese)</a>.</p>
*
* @author raysaoliveira
* @see #selectVmForCloudlet(Cloudlet)
*/
public final class CloudletTaskCompletionTimeMinimizationExperiment extends SimulationExperiment {
private static final int SCHEDULING_INTERVAL = 5;
Expand Down Expand Up @@ -259,24 +268,24 @@ protected void createBrokers() {
* Selects a VM to run a Cloudlet which minimizes the Cloudlet completion
* time.
*
* @param cl the Cloudlet to select a VM to
* @param cloudlet the Cloudlet to select a VM to
* @return the selected Vm
*/
private Vm selectVmForCloudlet(Cloudlet cl) {
final List<Vm> execVms = cl.getBroker().getVmExecList();
private Vm selectVmForCloudlet(Cloudlet cloudlet) {
final List<Vm> execVms = cloudlet.getBroker().getVmExecList();

final Comparator<Vm> sortByFreePesNumber = comparingLong(this::getExpectedNumberOfFreeVmPes);
final Comparator<Vm> sortByExpectedCloudletCompletionTime = comparingDouble(vm -> getExpectedCloudletCompletionTime(cl, vm));
final Comparator<Vm> sortByExpectedCloudletCompletionTime = comparingDouble(vm -> getExpectedCloudletCompletionTime(cloudlet, vm));
execVms.sort(
sortByExpectedCloudletCompletionTime.thenComparing(sortByFreePesNumber.reversed())
);
final Vm mostFreePesVm = execVms.stream().findFirst().orElse(Vm.NULL);

taskCompletionTimeSlaContract = contractsMap.get(cl.getBroker()).getTaskCompletionTimeMetric().getMaxDimension().getValue();
taskCompletionTimeSlaContract = contractsMap.get(cloudlet.getBroker()).getTaskCompletionTimeMetric().getMaxDimension().getValue();

return execVms.stream()
.filter(vm -> getExpectedNumberOfFreeVmPes(vm) >= cl.getNumberOfPes())
.filter(vm -> getExpectedCloudletCompletionTime(cl, vm) <= taskCompletionTimeSlaContract)
.filter(vm -> getExpectedNumberOfFreeVmPes(vm) >= cloudlet.getNumberOfPes())
.filter(vm -> getExpectedCloudletCompletionTime(cloudlet, vm) <= taskCompletionTimeSlaContract)
.findFirst()
.orElse(mostFreePesVm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,20 @@ public final class CloudSimTags {
*/
public static final int VM_VERTICAL_SCALING = BASE + 42;

/**
* Defines the tag to be used to send packets
* up through the network topology.
*/
public static final int NETWORK_EVENT_UP = BASE + 43;

public static final int NETWORK_EVENT_SEND = BASE + 44;

public static final int NETWORK_HOST_REGISTER = BASE + 45;

/**
* Defines the tag to be used to send packets
* down through the network topology.
*/
public static final int NETWORK_EVENT_DOWN = BASE + 46;

public static final int NETWORK_EVENT_HOST = BASE + 47;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class VmPacket implements NetworkPacket<Vm> {
/**
* Creates a packet to be sent to to a VM inside the
* Host of the sender VM.
* @param sourceVm id of the VM sending the packet
* @param sourceVm id of the VM sending the packet
* @param destinationVm id of the VM that has to receive the packet
* @param size data length of the packet in bytes
* @param senderCloudlet cloudlet sending the packet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
/**
* Implements a network layer by reading the topology from a file in the
* <a href="http://www.cs.bu.edu/brite/user_manual/node29.html">BRITE
* format</a>, the <a href="http://www.cs.bu.edu/brite/">Boston university
* Representative Topology gEnerator</a>, and generates a topological network
* format</a>, the <b>B</b>oston university
* <b>R</b>epresentative <b>I</b>nternet <b>T</b>opology g<b>E</b>nerator
* <a href="http://www.cs.bu.edu/brite/">(http://www.cs.bu.edu/brite/)</a>,
* and generates a topological network
* from it. Information of this network is used to simulate latency in network
* traffic of CloudSim.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* @since CloudSim Plus 1.0
*/
public interface NetworkTopology {

/**
* An attribute that implements the Null Object Design Pattern for {@link NetworkTopology}
* objects.
Expand All @@ -37,13 +36,15 @@ public interface NetworkTopology {
* destination node
* @param bw Link's bandwidth
* @param lat link's latency
* @todo It should receive entities instead of IDs
*/
void addLink(long srcId, long destId, double bw, double lat);

/**
* Maps a CloudSim entity to a BRITE node in the network topology.
* @param cloudSimEntityID ID of the entity being mapped
* @param cloudSimEntityID ID of the entity being mapped
* @param briteID ID of the BRITE node that corresponds to the CloudSim
* @todo It should receive an CloudSim entity instead of an ID
*/
void mapNode(long cloudSimEntityID, int briteID);

Expand All @@ -52,6 +53,7 @@ public interface NetworkTopology {
* topology.
*
* @param cloudSimEntityID ID of the entity being unmapped
* @todo It should receive an CloudSim entity instead of an ID
*/
void unmapNode(long cloudSimEntityID);

Expand All @@ -63,6 +65,7 @@ public interface NetworkTopology {
* @param destID ID of the CloudSim entity that represents the link's
* destination node
* @return communication delay between the two nodes
* @todo It should receive entities instead of IDs
*/
double getDelay(long srcID, long destID);

Expand Down

0 comments on commit 5b42f48

Please sign in to comment.