DatacenterBroker

public interface DatacenterBroker extends SimEntity

Represents a broker acting on behalf of a cloud customer. It hides VM management such as vm creation, submission of cloudlets to VMs and destruction of VMs.

A broker implements the policies for selecting a VM to run a Cloudlet and a Datacenter to run the submitted VMs.

Author:Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho

Fields

DEFAULT_VM_DESTRUCTION_DELAY

double DEFAULT_VM_DESTRUCTION_DELAY

A default delay value to indicate that no VM should be immediately destroyed after it becoming idle.

This is used as the default value returned by the getVmDestructionDelayFunction() if a Function is not set.

See also: .setVmDestructionDelayFunction(Function)

LOGGER

Logger LOGGER

NULL

DatacenterBroker NULL

An attribute that implements the Null Object Design Pattern for DatacenterBroker objects.

Methods

addOnVmsCreatedListener

DatacenterBroker addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)

Adds an EventListener that will be notified every time VMs in the waiting list are all created.

Events are fired according to the following conditions:

  • if all VMs are submitted before the simulation start and all those VMs are created after starting, then the event will be fired just once, during all simulation execution, for every registered Listener;
  • if all VMs submitted at a given time cannot be created due to lack of suitable Hosts, the event will not be fired for that submission;
  • if new VMs are submitted during simulation execution, the event may be fired multiple times. For instance, consider new VMs are submitted during simulation execution at times 10 and 20. If for every submission time, all VMs could be created, then every Listener will be notified 2 times (one for VMs submitted at time 10 and other for those at time 20).
Parameters:
  • listener – the Listener that will be notified

See also: .getVmWaitingList(), .addOneTimeOnVmsCreatedListener(EventListener)

addOneTimeOnVmsCreatedListener

DatacenterBroker addOneTimeOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)

Adds an EventListener that will be notified just once when VMs in the waiting list are all created. After the first notification, the Listener is removed from the registered Listeners and no further notifications will be sent to that specific Listener.

Even if VMs were submitted at different simulation times and all of them are created successfully (which means notifications are expected at different times), this Listener will be notified just when the first list of VMs is created and no subsequent notifications will be sent when other List of VMs is created.

For instance, consider new VMs are submitted during simulation execution at times 10 and 20. If for every submission time, all VMs could be created, then this specific Listener is expected to be notified 2 times (one for VMs submitted at time 10 and other for those at time 20). However, after VMs submitted at time 10 are all created, the Listener is notified and unregistered, so that it will get no next notifications.

Parameters:
  • listener – the Listener that will be notified

See also: .getVmWaitingList(), .addOnVmsCreatedListener(EventListener)

bindCloudletToVm

boolean bindCloudletToVm(Cloudlet cloudlet, Vm vm)

Specifies that an already submitted cloudlet, which is in the waiting list, must run in a specific virtual machine.

Parameters:
  • cloudlet – the cloudlet to be bind to a given Vm
  • vm – the vm to bind the Cloudlet to
Returns:

true if the Cloudlet was found in the waiting list and was bind to the given Vm, false it the Cloudlet was not found in such a list (that may mean it wasn’t submitted yet or was already created)

defaultVmMapper

Vm defaultVmMapper(Cloudlet cloudlet)

Defines the default policy used to select a Vm to host a Cloudlet that is waiting to be created. It applies a Round-Robin policy to cyclically select the next Vm from the list of waiting VMs.

Parameters:
  • cloudlet – the cloudlet that needs a VM to be placed into
Returns:

the selected Vm for the cloudlet or Vm.NULL if no suitable VM was found

getCloudletCreatedList

List<Cloudlet> getCloudletCreatedList()

Gets a read-only list of cloudlets created inside some Vm.

Returns:the list of created Cloudlets

getCloudletFinishedList

<T extends Cloudlet> List<T> getCloudletFinishedList()

Gets a copy of the list of cloudlets that have finished executing, to avoid the original list to be changed.

Parameters:
  • <T> – the class of Cloudlets inside the list
Returns:

the list of finished cloudlets

getCloudletSubmittedList

List<Cloudlet> getCloudletSubmittedList()

getCloudletWaitingList

<T extends Cloudlet> List<T> getCloudletWaitingList()

Gets the list of cloudlets submitted to the broker that are waiting to be created inside some Vm yet.

Parameters:
  • <T> – the class of Cloudlets inside the list
Returns:

the cloudlet waiting list

getVmCreatedList

<T extends Vm> List<T> getVmCreatedList()

Gets the list of all VMs created so far, independently if they are running yet or were already destroyed. This can be used at the end of the simulation to know which VMs have executed.

Parameters:
  • <T> – the class of VMs inside the list
Returns:

the list of created VMs

See also: .getVmExecList()

getVmDestructionDelayFunction

Function<Vm, Double> getVmDestructionDelayFunction()

Gets a Function which defines when an idle VM should be destroyed. The Function receives a Vm and returns the delay to wait (in seconds), after the VM becomes idle, to destroy it.

See also: .DEFAULT_VM_DESTRUCTION_DELAY, Vm.getIdleInterval()

getVmExecList

<T extends Vm> List<T> getVmExecList()

Gets the list of VMs in execution, if they are running Cloudlets or not. These VMs can receive new submitted Cloudlets.

Parameters:
  • <T> – the class of VMs inside the list
Returns:

the list of running VMs

See also: .getVmCreatedList()

getVmWaitingList

<T extends Vm> List<T> getVmWaitingList()

Gets a List of VMs submitted to the broker that are waiting to be created inside some Datacenter yet.

Parameters:
  • <T> – the class of VMs inside the list
Returns:

the list of waiting VMs

getWaitingVm

Vm getWaitingVm(int index)

isThereWaitingCloudlets

boolean isThereWaitingCloudlets()

Indicates if there are more cloudlets waiting to be executed yet.

Returns:true if there are waiting cloudlets, false otherwise

setCloudletComparator

void setCloudletComparator(Comparator<Cloudlet> comparator)

Sets a Comparator that will be used to sort every list of submitted Cloudlets before mapping each Cloudlet to a Vm. After sorting, the Cloudlet mapping will follow the order of the sorted Cloudlet list.

Parameters:
  • comparator – the Cloudlet Comparator to set

setDatacenterSupplier

void setDatacenterSupplier(Supplier<Datacenter> datacenterSupplier)

Sets the Supplier that selects and returns a Datacenter to place submitted VMs.

The supplier defines the policy to select a Datacenter to host a VM that is waiting to be created.

Parameters:
  • datacenterSupplier – the datacenterSupplier to set

setFallbackDatacenterSupplier

void setFallbackDatacenterSupplier(Supplier<Datacenter> fallbackDatacenterSupplier)

Sets the Supplier that selects and returns a fallback Datacenter to place submitted VMs when the Datacenter selected by the Datacenter Supplier failed to create all requested VMs.

The supplier defines the policy to select a Datacenter to host a VM when all VM creation requests were received but not all VMs could be created. In this case, a different Datacenter has to be selected to request the creation of the remaining VMs in the waiting list.

Parameters:
  • fallbackDatacenterSupplier – the fallbackDatacenterSupplier to set

setVmComparator

void setVmComparator(Comparator<Vm> comparator)

Sets a Comparator that will be used to sort every list of submitted VMs before requesting the creation of such VMs in some Datacenter. After sorting, the VM creation requests will be sent in the order of the sorted VM list.

Parameters:
  • comparator – the VM Comparator to set

setVmDestructionDelayFunction

DatacenterBroker setVmDestructionDelayFunction(Function<Vm, Double> function)

Sets a Function to define when an idle VM should be destroyed. The Function receives a Vm and returns the delay to wait (in seconds), after the VM becomes idle, to destroy it.

Parameters:
  • function – the Function to set (if null is given, it sets the default Function)

See also: .DEFAULT_VM_DESTRUCTION_DELAY, Vm.getIdleInterval()

setVmMapper

void setVmMapper(Function<Cloudlet, Vm> vmMapper)

Sets a Function that maps a given Cloudlet to a Vm. It defines the policy used to select a Vm to host a Cloudlet that is waiting to be created.

Parameters:
  • vmMapper – the Vm mapper Function to set. Such a Function must receive a Cloudlet and return the Vm where it will be placed into. If the Function is unable to find a VM for a Cloudlet, it should return Vm.NULL.

submitCloudlet

void submitCloudlet(Cloudlet cloudlet)

Submits a single Cloudlet to the broker.

Parameters:
  • cloudlet – the Cloudlet to be submitted

submitCloudletList

void submitCloudletList(List<? extends Cloudlet> list)

Sends a list of cloudlets to the broker so that it requests their creation inside some VM, following the submission delay specified in each cloudlet (if any). All cloudlets will be added to the getCloudletWaitingList().

Parameters:
  • list – the list of Cloudlets to request the creation

See also: .submitCloudletList(java.util.List,double)

submitCloudletList

void submitCloudletList(List<? extends Cloudlet> list, double submissionDelay)

Sends a list of cloudlets to the broker so that it requests their creation inside some VM just after a given delay. Just the Cloudlets that don’t have a delay already assigned will have its submission delay changed. All cloudlets will be added to the getCloudletWaitingList(), setting their submission delay to the specified value.

Parameters:
  • list – the list of Cloudlets to request the creation
  • submissionDelay – the delay the broker has to include when requesting the creation of Cloudlets

See also: .submitCloudletList(java.util.List), Cloudlet.getSubmissionDelay()

submitCloudletList

void submitCloudletList(List<? extends Cloudlet> list, Vm vm)

Sends a list of cloudlets to the broker so that it requests their creation inside a specific VM, following the submission delay specified in each cloudlet (if any). All cloudlets will be added to the getCloudletWaitingList().

Parameters:
  • list – the list of Cloudlets to request the creation
  • vm – the VM to which all Cloudlets will be bound to

See also: .submitCloudletList(java.util.List,double)

submitCloudletList

void submitCloudletList(List<? extends Cloudlet> list, Vm vm, double submissionDelay)

Sends a list of cloudlets to the broker so that it requests their creation inside a specific VM just after a given delay. Just the Cloudlets that don’t have a delay already assigned will have its submission delay changed. All cloudlets will be added to the getCloudletWaitingList(), setting their submission delay to the specified value.

Parameters:
  • list – the list of Cloudlets to request the creation
  • vm – the VM to which all Cloudlets will be bound to
  • submissionDelay – the delay the broker has to include when requesting the creation of Cloudlets

See also: .submitCloudletList(java.util.List), Cloudlet.getSubmissionDelay()

submitVm

void submitVm(Vm vm)

Submits a single Vm to the broker.

Parameters:
  • vm – the Vm to be submitted

submitVmList

void submitVmList(List<? extends Vm> list)

Sends to the broker a list with VMs that their creation inside a Host will be requested to some Datacenter. The Datacenter that will be chosen to place a VM is determined by the setDatacenterSupplier(Supplier).

Parameters:
  • list – the list of VMs to request the creation

submitVmList

void submitVmList(List<? extends Vm> list, double submissionDelay)

Sends a list of VMs for the broker so that their creation inside some Host will be requested just after a given delay. Just the VMs that don’t have a delay already assigned will have its submission delay changed. All VMs will be added to the getVmWaitingList(), setting their submission delay to the specified value.

Parameters:
  • list – the list of VMs to request the creation
  • submissionDelay – the delay the broker has to include when requesting the creation of VMs

See also: .submitVmList(java.util.List), Vm.getSubmissionDelay()