Code Monkey home page Code Monkey logo

cloudsimplus-examples's Introduction

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 download 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:

  • Open/import the project in your IDE:
    • For NetBeans, just use the "Open project" menu and select the directory where the project was downloaded/cloned. Check a NetBeans tutorial here.
    • For Eclipse or IntelliJ IDEA, you have to import the project selecting the folder where the project was cloned. Check an Eclipse tutorial here.
  • The most basic examples are in the root of the org.cloudsimplus.examples package. You can run any one of the classes in this package to get a specific example.
  • If you want to build your own simulations, the easiest way is to create another class inside this project.

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.

cloudsimplus-examples's People

Contributors

manoelcampos avatar sohamchari avatar struffel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cloudsimplus-examples's Issues

NetworkVmsExampleSimpleApp does not work

To report an issue or feature request, you have to provide the information below.

WHEN REPORTING AN ISSUE:

Actual behavior

Simply running the NetworkVmsExampleSimpleApp (or NetworkVmsExampleBagOfTasksApp or NetworkVmsExampleWorkflowApp) without any changes after cloning this repository, the simulation ends earlier than expected with a default warning where a VM with running cloudlets inside.

Here are the logs:

`INFO
================== Starting CloudSim Plus 8.5.0 ==================

INFO 0.00: #Datacenter 1 is starting...
INFO org.cloudsimplus.network.switches.EdgeSwitch@49b1985 is starting...
INFO Broker 3 is starting...
INFO Entities started.
INFO 0.00: DatacenterBrokerSimple3: List of 1 datacenters(s) received.
INFO 0.00: DatacenterBrokerSimple3: Trying to create Vm 0 inside #Datacenter 1
INFO 0.00: DatacenterBrokerSimple3: Trying to create Vm 1 inside #Datacenter 1
INFO 0.00: NetworkHost: Vm 0 is booting up right away in Host 0/#DC 1, since no startup delay (boot time) was set.
INFO 0.00: VmAllocationPolicySimple: Vm 0 has been allocated to Host 0/#DC 1
INFO 0.00: NetworkHost: Vm 1 is booting up right away in Host 1/#DC 1, since no startup delay (boot time) was set.
INFO 0.00: VmAllocationPolicySimple: Vm 1 has been allocated to Host 1/#DC 1
INFO 0.10: DatacenterBrokerSimple3: Sending Cloudlet 0 to Vm 0 inside Host 0/#DC 1.
INFO 0.10: DatacenterBrokerSimple3: Sending Cloudlet 1 to Vm 1 inside Host 1/#DC 1.
INFO 0.10: DatacenterBrokerSimple3: All 2 waiting Cloudlets submitted to some VM.
INFO 4.10: Processing last events before simulation shutdown.
INFO 4.10: DatacenterBrokerSimple3 is shutting down...
INFO 4.10: NetworkVm: Requesting Vm 1 destruction on Host 1/#DC 1. Shutdown will finish immediately (since no Vm shutDownDelay was set).
INFO 4.10: NetworkVm: Requesting Vm 0 destruction on Host 0/#DC 1. Shutdown will finish immediately (since no Vm shutDownDelay was set).
WARN 4.10: #Datacenter 1: Vm 1 destroyed on Host 1/#DC 1. It had a total of 1 cloudlets (running + waiting). Some events may have been missed. You can try:
(a) decreasing CloudSim's minTimeBetweenEvents and/or Datacenter's schedulingInterval attribute;
(b) increasing broker's Vm destruction delay for idle VMs if you set it to zero;
(c) defining Cloudlets with smaller length (your Datacenter's scheduling interval may be smaller than the time to finish some Cloudlets).

WARN 4.10: #Datacenter 1: Vm 0 destroyed on Host 0/#DC 1. It had a total of 1 cloudlets (running + waiting). Some events may have been missed. You can try:
(a) decreasing CloudSim's minTimeBetweenEvents and/or Datacenter's schedulingInterval attribute;
(b) increasing broker's Vm destruction delay for idle VMs if you set it to zero;
(c) defining Cloudlets with smaller length (your Datacenter's scheduling interval may be smaller than the time to finish some Cloudlets).

INFO Simulation: No more future events

INFO CloudInformationService0: Notify all CloudSim Plus entities to shutdown.

INFO EdgeSwitch2 is shutting down...
INFO
================== Simulation finished at time 4.10 ==================

                                           SIMULATION RESULTS
Cloudlet Status DC Host Host PEs VM VM PEs CloudletLen FinishedLen CloudletPEs StartTime FinishTime ExecTime
ID ID ID CPU cores ID CPU cores MI MI CPU cores Seconds Seconds Seconds

Host 0 data transferred: 0 bytes
Host 1 data transferred: 0 bytes
NetworkVmsExampleSimpleApp finished!

Process finished with exit code 0`

Expected behavior

Cloudlets will be finished running before the VM gets destroyed. I am not sure, what the value of schedulingInterval to use or other numbers to change.

What I have tried

I tried setVmDestructionDelayFunction() on broker, setShutDownDelay() and setShutDownBeginTime() on VM, but nothing. I also tried overwriting processVmDestroy(), however, it seems like broker is getting destroyed by itself.

Specifications like the version of the project, operating system or workload file used:

OS: Mac OS Monterey, 12.6
Version: CloudSim Plus 8.5.0
JDK: 21

Place VMs to a specified datacenter

Detailed information about how the feature should work

I want to place the current VM to a specified datacenter. For example, I have two Vms and two datacenters. I want to place Vm0 to datacenter0 and Vm1 to datacenter1. (Each datacenter has PEs that place two VMs at the same time)
As for the placement of Vm and Datacenter, I only know that VmAllocationPolicy is used to place Vm to the specified Host in the same datacenter. DatacenterSelectionByTimeZoneExample and SelectNextDatacenterExample of the cloudsim plus example module may also be related to this problem, but the situation is different.
I want to know if there are any relevant examples to place VMs in a specified datacenter,thanks!

A brief explanation of why you think this feature is useful

Datacenters may have different characteristics, for example, their prices are different, and their performance is different. Therefore, when the Cloudlet comes, you need to allocate an appropriate Vm to the Cloudlet and place it in a more appropriate datacenter (for example, higher cost performance, or better matching of other parameters). This issue is also worthy of our attention.

Introduced Example

Datacenter scheduling interval is not working for CloudletLifeTimeExample

ISSUE

Actual behavior

Despite setting a scheduling interval, the simulation is not updated at the defined time interval. Cloudlets processing logs are just shown when Cloudlets start and finish. This may be related to the example configuration or some CloudSim Plus issue.

Expected behavior

Setting a scheduling interval should make the simulation to be updated at the defined time interval, printing logs in such interval.

Specifications like the version of the project, operating system or workload file used

CloudSim Plus 8.0.0

Hi , in my opinion in cloudlet dynamic arrival2 the execution time for 3 cloudlets are not proper. Kindly look into it and correct me if I am wrong.

WHEN REPORTING AN ISSUE:

Actual behavior

Expected behavior

If the issue is related to a specific method, provide a test case that fails in order to show the problem

If it is a wider problem or you don't know where it happens, please provide a minimal simulation example which reproduces the problem

Specifications like the version of the project, operating system or workload file used


WHEN REQUESTING A FEATURE:

Detailed information about how the feature should work

An example scenario where this feature should be used

A brief explanation of why you think this feature is useful

Parallel executions in CloudSimPlus

I'm trying to execute 2 CloudSimPlus simulations on the same Java VM in order to train 2 different Reinforcement Learning agents. For some reason I keep getting only 1 simulation running when running them in different threads.

Can CloudSimPlus execute in this way or should I run them in different VMs?

Some examples are using UtilizationModelFull for RAM and BW, causing resource unavailability and wrong simulation time

ISSUE

Actual behavior

Running some examples, such as CloudletSchedulerTimeSharedExample1.java in org.cloudsimplus.examples.schedulers, throws several warnings that cloudlets can't allocate enough RAM and bandwidth.

This causes the execution time of the second cloudlet to spike to astronimical levels, which I don't believe to be the desired behavior in this demo.
(Note about the included log: I tried resolving this by increasing the resources of hosts and vms which changes the absolute values but didn't resolve the issue.)

�[34mINFO  
================== Starting CloudSim Plus 7.3.0 ==================

�[0;39m�[34mINFO  0,00: DatacenterSimple1 is starting...
�[0;39m�[34mINFO  DatacenterBrokerSimple2 is starting...
�[0;39m�[34mINFO  Entities started.
�[0;39m�[34mINFO  0,00: DatacenterBrokerSimple2: List of 1 datacenters(s) received.
�[0;39m�[34mINFO  0,00: DatacenterBrokerSimple2: Trying to create Vm 0 in DatacenterSimple1
�[0;39m�[34mINFO  0,00: VmAllocationPolicySimple: Vm 0 has been allocated to Host 0/DC 1
�[0;39m�[34mINFO  0,10: DatacenterBrokerSimple2: Sending Cloudlet 0 to Vm 0 in Host 0/DC 1.
�[0;39m�[34mINFO  0,10: DatacenterBrokerSimple2: Sending Cloudlet 1 to Vm 0 in Host 0/DC 1.
�[0;39m�[34mINFO  0,10: DatacenterBrokerSimple2: All 2 waiting Cloudlets submitted to some VM.
�[0;39m�[31mWARN  10,10: CloudletSchedulerTimeShared: Cloudlet 1 requested 2048 MB of Ram but no amount is available.. Using Virtual Memory, which delays Cloudlet processing.
�[0;39m�[31mWARN  10,10: CloudletSchedulerTimeShared: Cloudlet 1 requested 2000 Mbps of Bandwidth but no amount is available., which delays Cloudlet processing.
�[0;39m�[31mWARN  20,00: CloudletSchedulerTimeShared: Cloudlet 1 requested 2048 MB of Ram but no amount is available.. Using Virtual Memory, which delays Cloudlet processing.
�[0;39m�[31mWARN  20,00: CloudletSchedulerTimeShared: Cloudlet 1 requested 2000 Mbps of Bandwidth but no amount is available., which delays Cloudlet processing.
�[0;39m�[31mWARN  20,11: CloudletSchedulerTimeShared: Cloudlet 1 requested 2048 MB of Ram but no amount is available.. Using Virtual Memory, which delays Cloudlet processing.
�[0;39m�[31mWARN  20,11: CloudletSchedulerTimeShared: Cloudlet 1 requested 2000 Mbps of Bandwidth but no amount is available., which delays Cloudlet processing.
�[0;39m�[34mINFO  20,11: DatacenterBrokerSimple2: Cloudlet 0 finished in Vm 0 and returned to broker.
�[0;39m�[34mINFO  9223372066,74: DatacenterBrokerSimple2: Cloudlet 1 finished in Vm 0 and returned to broker.
�[0;39m�[34mINFO  9223372066,96: Processing last events before simulation shutdown.
�[0;39m�[34mINFO  9223372066,96: DatacenterBrokerSimple2 is shutting down...
�[0;39m�[34mINFO  9223372066,96: DatacenterBrokerSimple2: Requesting Vm 0 destruction.
�[0;39m�[34mINFO  9223372066,96: DatacenterSimple: Vm 0 destroyed on Host 0/DC 1. 
�[0;39m�[34mINFO  Simulation: No more future events

�[0;39m�[34mINFO  CloudInformationService0: Notify all CloudSim Plus entities to shutdown.

�[0;39m�[34mINFO  
================== Simulation finished at time 9223372066,96 ==================

�[0;39m

Expected behavior

Based on the comment I would expect both VMs to finish at the same time.

If the issue is related to a specific method, provide a test case that fails in order to show the problem

N/A

If it is a wider problem or you don't know where it happens, please provide a minimal simulation example which reproduces the problem

In think this has to do with the utilization model that is created in line 168. It requests 100% of all resources not just for the CPU but also for all the other resources. I replaced it with a new UtilizationModelDynamic(0.5); and was able to get both VMs to finish at the same time (though twice as slow obviously). But this kind of misses the point of the demo as far as I see it.

Specifications like the version of the project, operating system or workload file used

Cloudsimplus-examples, commit ff8c7f6 (latest as of right now)
Run in Eclipse as a maven project with openjdk 17.0.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.