cloudsimplus / cloudsimplus-examples

CloudSim Plus Examples: the starting point to understand how to use the framework and create your own simulations
https://cloudsimplus.org
GNU General Public License v3.0
22 stars 19 forks source link
cloud-computing cloudsim cloudsimplus examples framework jdk17 simulation

CloudSim Plus Examples Build Status

Open in Gitpod

This module contains several CloudSim Plus examples, including those inherited from CloudSim and new ones for exclusive features. Those later ones are available into the org.cloudsimplus.examples package. They have more meaningful names, making it easier to get an overview of what an example is about, before even opening it.

To get started you can check the ReducedExample.java, which shows the minimum code required to build cloud simulations using CloudSim Plus. The example places all the required code inside the main() method just for convenience, making it easier for new users to understand the code.

However, that code is not reusable. If you try to build simulations that way, you'll end up with a messy and duplicated code. Therefore, after you understood how to build basic simulations, you may want to try checking the BasicFirstExample.java. It's a structured and reusable code that gives a picture of the best ways to write your simulations.

1. Project Requirements

CloudSim Plus Examples is a Java 17 project that uses maven for build and dependency management. To build and run the project, you need JDK 17+ installed.

All project dependencies are downloaded automatically by maven (including CloudSim Plus jars).

2. Downloading the Project Sources

You can download this project using (i) the download button on top of this page (ii) your own IDE for it or (iii) the command line as described below.

Via Command Line

Considering that you have git installed on your operating system, download the project source by cloning the repository issuing the following command at a terminal:

git clone https://github.com/cloudsimplus/cloudsimplus-examples.git

3. Building the Examples

CloudSim Plus Examples is a maven project, therefore to build it, you have two ways:

3.1 Using some IDE

Open the project on your favorite IDE and click the build button and that is it.

3.1 Using a terminal

Open a terminal at the project root directory and type one of the following commands:

on Linux/macOS

./mvnw clean install
./mvnw dependency:resolve -Dclassifier=javadoc

on Windows

mvnw.cmd clean install
mvnw.cmd dependency:resolve -Dclassifier=javadoc

The second command is optional but very useful to download CloudSim Plus JavaDocs and help you understand the API inside your IDE.

4. Running Examples

There are 2 ways to run the examples in this project, as presented below.

4.1 Using some IDE

The easiest way to run the examples is relying on some IDE. Below are required steps:

4.2 Using the bootstrap.sh script

The project has a bootstrap.sh script you can use to build and run CloudSim Plus examples. This is a script for Unix-like systems such as Linux, FreeBSD and macOS.

To run some example, type the following command at a terminal inside the project's root directory: sh bootstrap.sh package.ExampleClassName. For instance, to run the BasicFirstExample you can type: sh bootstrap.sh org.cloudsimplus.examples.BasicFirstExample.

The script checks if it is required to build the project, using maven in this case, making sure to download all dependencies. To see which examples are available, just navigate through the src/main/java directory. To check more script options, run it without any parameter.