Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
import java.util.ArrayList;
import java.util.List;

/**
* A simple example showing how to create a Datacenter with 1 host and a network
* topology, running 1 cloudlet on it.
* There is just one VM with a single PE of 250 MIPS.
* The Cloudlet requires 1 PE and has a length of 40000 MI.
* This way, the Cloudlet will take 160 seconds to finish (40000/250).
*
* <p>The Cloudlet is not requiring any files from a {@link SanStorage},
* but since a network topology is defined from the file topology.brite,
* communication delay between network elements is simulated,
* causing the Cloudlet to start executing just after a few seconds.</p>
*/
/// A simple example showing how to create a Datacenter with 1 host and a network
/// topology, running 1 cloudlet on it.
/// There is just one VM with a single PE of 250 MIPS.
/// The Cloudlet requires 1 PE and has a length of 40000 MI.
/// This way, the Cloudlet will take 160 seconds to finish (40000/250).
///
/// The Cloudlet is not requiring any files from a [SanStorage],
/// but since a network topology is defined from the file topology.brite,
/// communication delay between network elements is simulated,
/// causing the Cloudlet to start executing just after a few seconds.
public class NetworkExample1 {
private static final String NETWORK_TOPOLOGY_FILE = "topology.brite";
private static final int VM_PES = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
import java.util.ArrayList;
import java.util.List;

/**
* A simple example showing how to create 2 datacenters with 1 host.
* It sets a network topology and then run 2 cloudlets.
*/
/// A simple example showing how to create 2 datacenters with 1 host.
/// It sets a network topology and then run 2 cloudlets.
public class NetworkExample2 {
private static final String NETWORK_TOPOLOGY_FILE = "topology.brite";
private static final int VM_PES = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
import java.util.ArrayList;
import java.util.List;

/**
* A simple example showing how to create 2 datacenters with 1 host each and run
* cloudlets of 2 users. It also sets a network topology.
*/
/// A simple example showing how to create 2 datacenters with 1 host each and run
/// cloudlets of 2 users. It also sets a network topology.
public class NetworkExample3 {
private static final int VM_PES = 1;

Expand Down Expand Up @@ -135,9 +133,7 @@ private void createAndSubmitVms() {
brokerList.get(1).submitVmList(vmList2);
}

/**
* Creates the network topology from a brite file.
*/
/// Creates the network topology from a brite file.
private void createNetwork() {
//load the network topology file
final var networkTopology = BriteNetworkTopology.getInstance("topology.brite");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,22 @@
import java.util.ArrayList;
import java.util.List;

/**
* A simple example showing how to create a Datacenter with 1 host and a network
* topology, running 1 cloudlet on it. Here, instead of using a BRITE file
* describing the links, they are just inserted in the code.
*
* <p>The example defines a given latency for communication with the created broker.
* Since the broker receives multiple messages (such as for VM and Cloudlet creation),
* cloudlets start running just after such multiple messages are received.
* If 3 messages are sent to the broker for starting a Cloudlet,
* the total delay is the network latency multiplied by 3.</p>
*/
/// A simple example showing how to create a Datacenter with 1 host and a network
/// topology, running 1 cloudlet on it. Here, instead of using a BRITE file
/// describing the links, they are just inserted in the code.
///
/// The example defines a given latency for communication with the created broker.
/// Since the broker receives multiple messages (such as for VM and Cloudlet creation),
/// cloudlets start running just after such multiple messages are received.
/// If 3 messages are sent to the broker for starting a Cloudlet,
/// the total delay is the network latency multiplied by 3.
public class NetworkExample4 {
private static final int VM_PES = 1;

/** In Megabits/s. */
/// In Megabits/s.
private static final double NETWORK_BW = 10.0;

/** In seconds. */
/// In seconds.
private static final double NETWORK_LATENCY = 10.0;

private final DatacenterBroker broker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@
import java.util.List;
import java.util.Map;

/**
* A base class for network simulation examples
* using objects such as{@link NetworkDatacenter},
* {@link NetworkHost}, {@link NetworkVm} and {@link NetworkCloudlet}.
*
* <p>The class simulate applications that are compounded by a list of
* {@link NetworkCloudlet}.</p>
*
* @author Saurabh Kumar Garg
* @author Rajkumar Buyya
* @author Manoel Campos da Silva Filho
*/
/// A base class for network simulation examples
/// using objects such as[NetworkDatacenter],
/// [NetworkHost], [NetworkVm] and [NetworkCloudlet].
///
/// The class simulate applications that are compounded by a list of
/// [NetworkCloudlet].
///
/// @author Saurabh Kumar Garg
/// @author Rajkumar Buyya
/// @author Manoel Campos da Silva Filho
abstract class NetworkVmExampleAbstract {
public static final int MAX_VMS_PER_HOST = 2;

Expand All @@ -57,11 +55,9 @@ abstract class NetworkVmExampleAbstract {
public static final long VM_BW = 1000;
public static final int VM_PES_NUMBER = HOST_PES / MAX_VMS_PER_HOST;

/**
* Number of fictitious applications to create.
* Each application is just a list of {@link NetworkCloudlet}.
* @see #appMap
*/
/// Number of fictitious applications to create.
/// Each application is just a list of [NetworkCloudlet].
/// @see #appMap
public static final int APPS_NUMBER = 1;

public static final int CLOUDLET_PES = VM_PES_NUMBER;
Expand All @@ -79,16 +75,12 @@ abstract class NetworkVmExampleAbstract {
private final NetworkDatacenter datacenter;
private final List<DatacenterBroker> brokerList;

/**
* A Map representing a list of cloudlets from different applications.
* Each key represents the ID of an app that is composed by a list
* of {@link NetworkCloudlet}.
*/
/// A Map representing a list of cloudlets from different applications.
/// Each key represents the ID of an app that is composed by a list
/// of [NetworkCloudlet].
private final Map<Integer, List<NetworkCloudlet>> appMap;

/**
* Creates, starts, stops the simulation and shows results.
*/
/// Creates, starts, stops the simulation and shows results.
NetworkVmExampleAbstract() {
/*Enables just some level of log messages.
Make sure to import org.cloudsimplus.util.Log;*/
Expand All @@ -112,11 +104,9 @@ abstract class NetworkVmExampleAbstract {
showSimulationResults();
}

/**
* Adds an execution task to the list of tasks of the given {@link NetworkCloudlet}.
*
* @param cloudlet the {@link NetworkCloudlet} the task will belong to
*/
/// Adds an execution task to the list of tasks of the given [NetworkCloudlet].
///
/// @param cloudlet the [NetworkCloudlet] the task will belong to
protected static void addExecutionTask(NetworkCloudlet cloudlet) {
final var task = new CloudletExecutionTask(cloudlet.getTasks().size(), TASK_LENGTH);
task.setMemory(TASK_RAM);
Expand Down Expand Up @@ -144,12 +134,10 @@ private void showSimulationResults() {
System.out.printf("%n%s finished!%n", getClass().getSimpleName());
}

/**
* Create a {@link DatacenterBroker} for each list of {@link NetworkCloudlet},
* representing cloudlets that compose the same application.
*
* @return the list of created NetworkDatacenterBroker
*/
/// Create a [DatacenterBroker] for each list of [NetworkCloudlet],
/// representing cloudlets that compose the same application.
///
/// @return the list of created NetworkDatacenterBroker
private List<DatacenterBroker> createBrokerForEachApp() {
final var brokerList = new ArrayList<DatacenterBroker>();
for(int i = 1; i <= APPS_NUMBER; i++){
Expand All @@ -159,11 +147,9 @@ private List<DatacenterBroker> createBrokerForEachApp() {
return brokerList;
}

/**
* Creates the Datacenter.
*
* @return the Datacenter
*/
/// Creates the Datacenter.
///
/// @return the Datacenter
protected final NetworkDatacenter createDatacenter() {
final int hostsNumber = EdgeSwitch.PORTS * AggregateSwitch.PORTS * RootSwitch.PORTS;
final var netHostList = new ArrayList<NetworkHost>(hostsNumber);
Expand Down Expand Up @@ -198,10 +184,8 @@ protected List<Pe> createPEs(final int pesNumber, final long mips) {
return peList;
}

/**
* Creates internal Datacenter network.
* @param datacenter Datacenter where the network will be created
*/
/// Creates internal Datacenter network.
/// @param datacenter Datacenter where the network will be created
protected void createNetwork(final NetworkDatacenter datacenter) {
final var edgeSwitches = new EdgeSwitch[1];
for (int i = 0; i < edgeSwitches.length; i++) {
Expand All @@ -215,31 +199,27 @@ protected void createNetwork(final NetworkDatacenter datacenter) {
}
}

/**
* Gets the index of a switch where a Host will be connected,
* considering the number of ports the switches have.
* Ensures that each set of N Hosts is connected to the same switch
* (where N is defined as the number of switch's ports).
* Since the host ID is long but the switch array index is int,
* the module operation is used safely convert a long to int
* For instance, if the id is 2147483648 (higher than the max int value 2147483647),
* it will be returned 0. For 2147483649 it will be 1 and so on.
*
* @param host the Host to get the index of the switch to connect to
* @param switchPorts the number of ports (N) the switches where the Host will be connected have
* @return the index of the switch to connect the host
*/
/// Gets the index of a switch where a Host will be connected,
/// considering the number of ports the switches have.
/// Ensures that each set of N Hosts is connected to the same switch
/// (where N is defined as the number of switch's ports).
/// Since the host ID is long but the switch array index is int,
/// the module operation is used safely convert a long to int
/// For instance, if the id is 2147483648 (higher than the max int value 2147483647),
/// it will be returned 0. For 2147483649 it will be 1 and so on.
///
/// @param host the Host to get the index of the switch to connect to
/// @param switchPorts the number of ports (N) the switches where the Host will be connected have
/// @return the index of the switch to connect the host
public static int getSwitchIndex(final NetworkHost host, final int switchPorts) {
return (int) (host.getId() % Integer.MAX_VALUE) / switchPorts;
}

/**
* Creates a list of virtual machines in a Datacenter for a given broker
* and submit the list to the broker.
*
* @param broker The broker that will own the created VMs
* @return the list of created VMs
*/
/// Creates a list of virtual machines in a Datacenter for a given broker
/// and submit the list to the broker.
///
/// @param broker The broker that will own the created VMs
/// @return the list of created VMs
protected final List<NetworkVm> createAndSubmitVMs(DatacenterBroker broker) {
final int vmsNumber = getDatacenterHostList().size() * MAX_VMS_PER_HOST;
final var netVmList = new ArrayList<NetworkVm>();
Expand All @@ -260,9 +240,7 @@ private List<NetworkHost> getDatacenterHostList() {
return datacenter.getHostList();
}

/**
* @return List of VMs of all Brokers.
*/
/// @return List of VMs of all Brokers.
public List<NetworkVm> getVmList() {
return vmList;
}
Expand All @@ -275,34 +253,28 @@ public NetworkDatacenter getDatacenter() {
return datacenter;
}

/**
* Creates a list of {@link NetworkCloudlet}'s that represents
* a single application and then submits the created cloudlets to a given Broker.
*
* @param broker the broker to submit the list of NetworkCloudlets of the application
* @return the list of created {@link NetworkCloudlet}'s
*/
/// Creates a list of [NetworkCloudlet]'s that represents
/// a single application and then submits the created cloudlets to a given Broker.
///
/// @param broker the broker to submit the list of NetworkCloudlets of the application
/// @return the list of created [NetworkCloudlet]'s
protected final List<NetworkCloudlet> createAppAndSubmitToBroker(DatacenterBroker broker) {
final var netCloudletList = createNetworkCloudlets(broker);
broker.submitCloudletList(netCloudletList);
return netCloudletList;
}

/**
* Creates a list of {@link NetworkCloudlet} that together represents the distributed
* processes of a given application.
*
* @param broker broker to associate the NetworkCloudlets
* @return the list of create NetworkCloudlets
*/
/// Creates a list of [NetworkCloudlet] that together represents the distributed
/// processes of a given application.
///
/// @param broker broker to associate the NetworkCloudlets
/// @return the list of create NetworkCloudlets
protected abstract List<NetworkCloudlet> createNetworkCloudlets(DatacenterBroker broker);

/**
* Adds a SendTask to the list of tasks of the given {@link NetworkCloudlet}.
*
* @param sourceCloudlet the {@link NetworkCloudlet} from which packets will be sent
* @param targetCloudlet the destination {@link NetworkCloudlet} to send packets to
*/
/// Adds a SendTask to the list of tasks of the given [NetworkCloudlet].
///
/// @param sourceCloudlet the [NetworkCloudlet] from which packets will be sent
/// @param targetCloudlet the destination [NetworkCloudlet] to send packets to
protected void addSendTask(
final NetworkCloudlet sourceCloudlet,
final NetworkCloudlet targetCloudlet)
Expand All @@ -315,12 +287,10 @@ protected void addSendTask(
}
}

/**
* Adds a ReceiveTask to the list of tasks of the given {@link NetworkCloudlet}.
*
* @param targetCloudlet the {@link NetworkCloudlet} the task will belong to
* @param sourceCloudlet the {@link NetworkCloudlet} expected to receive packets from
*/
/// Adds a ReceiveTask to the list of tasks of the given [NetworkCloudlet].
///
/// @param targetCloudlet the [NetworkCloudlet] the task will belong to
/// @param sourceCloudlet the [NetworkCloudlet] expected to receive packets from
protected void addReceiveTask(final NetworkCloudlet targetCloudlet, final NetworkCloudlet sourceCloudlet) {
final var task = new CloudletReceiveTask(targetCloudlet.getTasks().size(), sourceCloudlet.getVm());
task.setMemory(TASK_RAM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@
import java.util.ArrayList;
import java.util.List;

/**
* An example of "Bag of Tasks" distributed application that is compounded by
* 3 {@link NetworkCloudlet}, where 2 of them send data to the first created one,
* which waits the data to be received.
*
* @author Saurabh Kumar Garg
* @author Rajkumar Buyya
* @author Manoel Campos da Silva Filho
*/
/// An example of "Bag of Tasks" distributed application that is compounded by
/// 3 [NetworkCloudlet], where 2 of them send data to the first created one,
/// which waits the data to be received.
///
/// @author Saurabh Kumar Garg
/// @author Rajkumar Buyya
/// @author Manoel Campos da Silva Filho
public class NetworkVmsExampleBagOfTasksApp extends NetworkVmExampleAbstract {
private static final long CLOUDLET_LENGTH = 1;

/**
* Starts the execution of the example.
* @param args
*/
/// Starts the execution of the example.
/// @param args
public static void main(String[] args) {
new NetworkVmsExampleBagOfTasksApp();
}
Expand Down
Loading
Loading