cloudsimplus / cloudsimplus

State-of-the-art Framework 🏗 for Cloud Computing ⛅️ Simulation: a modern, full-featured, easier-to-use, highly extensible 🧩, faster 🚀 and more accurate ☕️ Java 17+ tool for cloud computing research 🎓. Examples: https://github.com/cloudsimplus/cloudsimplus-examples

Home Page:https://cloudsimplus.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable a VM belonging to a broker to be destroyed after all its Cloudlets have finished, independently of the state of other running VMs and according to a given delay

manoelcampos opened this issue · comments

The DatacenterBroker only destroys VMs after:

  1. all submitted Cloudlets have finished and there aren't waiting Cloudlets;
  2. all running cloudlets have finished and there are some of them waiting their VMs to be created.

The broker should enable a new behaviour:

  1. allow destroying a given VM when all its Cloudlets finish executing, independently if all Cloudlets running in other VMs have finished or not. This way, that VM should be destroyed if it become idle (having no waiting or executing Cloudlets).

Implementation Details

A method setVmDestructionDelayFunction(final Function<Vm, Double> function) was introduced into the DatacenterBroker to enable setting a Function which defines the delay to destroy an idle VM. The Function given to the setter receives a VM and should return the time delay to destroy the VM after it becoming idle.

There are three different behaviours for VM destruction, considering the value returned by the given Function.

1. Default Behaviour if a Function is not set

If a Function is not set, VMs will be immediately destroyed when all submitted Cloudlets running in any VM have finished, independently if there aren't waiting VMs or not.
If a Cloudlet finishes but there are other running Cloudlets, no VM will be destroyed.

2. A Function is set and returns 0.0

When a Function is set and returns 0.0 as the destruction delay for a given VM, that VM will be destroyed immediately after it becoming idle, independently of any other condition.
That is, it doesn't matter if there are Cloudlets waiting to be created or running.

3. A Function is set and returns a positive value

When a Function is set and returns a positive value like 2 as the destruction delay for a given VM, that VM will be destroyed only after 2 seconds from becoming idle, independently of any other condition.

A brief explanation of why you think this feature is useful

While the behaviour of only destroying VMs after the broker shuts down is useful if more Cloudlets are expected to arrive (mainly after the issue #43), it is not always the case. If one wants to save resources, idle VMs should be destroyed so that VMs from other brokers can be created into the Host or even other VMs from the same broker.

On the other hand, if there is a set of VMs running in parallel to provide fault tolerance (see #81), it doesn't make sense to immediately destroy a VM after it becoming idle. Usually you may leave the VM running to simulate the waiting for user's requests or you may define an idleness limit to destroy the VM. This way, the Function<Vm,Double> allows defining such a behaviour.

Included Examples