Interface DatacenterBroker
-
- All Superinterfaces:
Cloneable
,Comparable<SimEntity>
,Identifiable
,Nameable
,Runnable
,SimEntity
- All Known Implementing Classes:
DatacenterBrokerAbstract
,DatacenterBrokerHeuristic
,DatacenterBrokerSimple
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.
- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.cloudbus.cloudsim.core.SimEntity
SimEntity.State
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEF_VM_DESTRUCTION_DELAY
A default delay value to indicate that NO VM should be immediately destroyed after becoming idle.static org.slf4j.Logger
LOGGER
static DatacenterBroker
NULL
An attribute that implements the Null Object Design Pattern forDatacenterBroker
objects.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DatacenterBroker
addOneTimeOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds anEventListener
that will be notified just once when VMs in the waiting list are all created.DatacenterBroker
addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds anEventListener
that will be notified every time VMs in the waiting list are all created.boolean
bindCloudletToVm(Cloudlet cloudlet, Vm vm)
Specifies that an already submitted cloudlet, which is in thewaiting list
, must run in a specific virtual machine.Vm
defaultVmMapper(Cloudlet cloudlet)
Defines the default policy used to select a Vm to host a Cloudlet that is waiting to be created.List<Cloudlet>
getCloudletCreatedList()
Gets a read-only list of cloudlets created inside some Vm.<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.List<Cloudlet>
getCloudletSubmittedList()
<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.<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.Function<Vm,Double>
getVmDestructionDelayFunction()
Gets aFunction
which defines when an idle VM should be destroyed.<T extends Vm>
List<T>getVmExecList()
Gets the list of VMs in execution, if they are running Cloudlets or not.<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.Vm
getWaitingVm(int index)
boolean
isThereWaitingCloudlets()
Indicates if there are more cloudlets waiting to be executed yet.void
setCloudletComparator(Comparator<Cloudlet> comparator)
Sets aComparator
that will be used to sort every list of submitted Cloudlets before mapping each Cloudlet to a Vm.void
setDatacenterSupplier(Supplier<Datacenter> datacenterSupplier)
Sets theSupplier
that selects and returns a Datacenter to place submitted VMs.void
setFallbackDatacenterSupplier(Supplier<Datacenter> fallbackDatacenterSupplier)
Sets theSupplier
that selects and returns a fallback Datacenter to place submitted VMs when the Datacenter selected by theDatacenter Supplier
failed to create all requested VMs.void
setVmComparator(Comparator<Vm> comparator)
Sets aComparator
that will be used to sort every list of submitted VMs before requesting the creation of such VMs in some Datacenter.DatacenterBroker
setVmDestructionDelayFunction(Function<Vm,Double> function)
Sets aFunction
to define when an idle VM should be destroyed.void
setVmMapper(Function<Cloudlet,Vm> vmMapper)
Sets aFunction
that maps a given Cloudlet to a Vm.void
submitCloudlet(Cloudlet cloudlet)
Submits a singleCloudlet
to the broker.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).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.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).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.void
submitVm(Vm vm)
Submits a singleVm
to the broker.void
submitVmList(List<? extends Vm> list)
Sends to the broker a list with VMs that their creation inside a Host will be requested to someDatacenter
.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.-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface org.cloudbus.cloudsim.core.Identifiable
getId
-
Methods inherited from interface org.cloudbus.cloudsim.core.SimEntity
getSimulation, getState, isAlive, isFinished, isStarted, processEvent, run, schedule, schedule, schedule, schedule, setName, setSimulation, setState, shutdownEntity, start
-
-
-
-
Field Detail
-
LOGGER
static final org.slf4j.Logger LOGGER
-
NULL
static final DatacenterBroker NULL
An attribute that implements the Null Object Design Pattern forDatacenterBroker
objects.
-
DEF_VM_DESTRUCTION_DELAY
static final double DEF_VM_DESTRUCTION_DELAY
A default delay value to indicate that NO VM should be immediately destroyed after becoming idle.This is used as the default value returned by the
getVmDestructionDelayFunction()
if aFunction
is not set.
-
-
Method Detail
-
bindCloudletToVm
boolean bindCloudletToVm(Cloudlet cloudlet, Vm vm)
Specifies that an already submitted cloudlet, which is in thewaiting list
, must run in a specific virtual machine.- Parameters:
cloudlet
- the cloudlet to be bind to a given Vmvm
- 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)
- Precondition:
- cloudletId > 0, id > 0
- Postcondition:
- $none
-
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.- Type Parameters:
T
- the class of Cloudlets inside the list- Returns:
- the cloudlet waiting list
-
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.- Type Parameters:
T
- the class of Cloudlets inside the list- Returns:
- the list of finished cloudlets
-
getWaitingVm
Vm getWaitingVm(int index)
-
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.- Type Parameters:
T
- the class of VMs inside the list- Returns:
- the list of waiting VMs
-
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.- Type Parameters:
T
- the class of VMs inside the list- Returns:
- the list of running VMs
- See Also:
getVmCreatedList()
-
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.- Type Parameters:
T
- the class of VMs inside the list- Returns:
- the list of created VMs
- See Also:
getVmExecList()
-
submitVm
void submitVm(Vm vm)
Submits a singleVm
to the broker.- Parameters:
vm
- the Vm to be submitted
-
submitCloudlet
void submitCloudlet(Cloudlet cloudlet)
Submits a singleCloudlet
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 thegetCloudletWaitingList()
.- Parameters:
list
- the list of Cloudlets to request the creation- See Also:
submitCloudletList(java.util.List, double)
- Precondition:
- list !=null
- Postcondition:
- $none
-
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 thegetCloudletWaitingList()
, setting their submission delay to the specified value.- Parameters:
list
- the list of Cloudlets to request the creationsubmissionDelay
- the delay the broker has to include when requesting the creation of Cloudlets- See Also:
submitCloudletList(java.util.List)
,Delayable.getSubmissionDelay()
- Precondition:
- list !=null
- Postcondition:
- $none
-
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 thegetCloudletWaitingList()
.- Parameters:
list
- the list of Cloudlets to request the creationvm
- the VM to which all Cloudlets will be bound to- See Also:
submitCloudletList(java.util.List, double)
- Precondition:
- list !=null
- Postcondition:
- $none
-
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 thegetCloudletWaitingList()
, setting their submission delay to the specified value.- Parameters:
list
- the list of Cloudlets to request the creationvm
- the VM to which all Cloudlets will be bound tosubmissionDelay
- the delay the broker has to include when requesting the creation of Cloudlets- See Also:
submitCloudletList(java.util.List)
,Delayable.getSubmissionDelay()
- Precondition:
- list !=null
- Postcondition:
- $none
-
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 someDatacenter
. The Datacenter that will be chosen to place a VM is determined by thesetDatacenterSupplier(Supplier)
.- Parameters:
list
- the list of VMs to request the creation- Precondition:
- list !=null
- Postcondition:
- $none
-
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 thegetVmWaitingList()
, setting their submission delay to the specified value.- Parameters:
list
- the list of VMs to request the creationsubmissionDelay
- the delay the broker has to include when requesting the creation of VMs- See Also:
submitVmList(java.util.List)
,Delayable.getSubmissionDelay()
- Precondition:
- list !=null
- Postcondition:
- $none
-
isThereWaitingCloudlets
boolean isThereWaitingCloudlets()
Indicates if there are more cloudlets waiting to be executed yet.- Returns:
- true if there are waiting cloudlets, false otherwise
-
setDatacenterSupplier
void setDatacenterSupplier(Supplier<Datacenter> datacenterSupplier)
Sets theSupplier
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 theSupplier
that selects and returns a fallback Datacenter to place submitted VMs when the Datacenter selected by theDatacenter 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 aComparator
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
-
setCloudletComparator
void setCloudletComparator(Comparator<Cloudlet> comparator)
Sets aComparator
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
-
setVmMapper
void setVmMapper(Function<Cloudlet,Vm> vmMapper)
Sets aFunction
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 returnVm.NULL
.
-
getCloudletCreatedList
List<Cloudlet> getCloudletCreatedList()
Gets a read-only list of cloudlets created inside some Vm.- Returns:
- the list of created Cloudlets
-
addOnVmsCreatedListener
DatacenterBroker addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds anEventListener
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- Returns:
- See Also:
getVmWaitingList()
,addOneTimeOnVmsCreatedListener(EventListener)
-
addOneTimeOnVmsCreatedListener
DatacenterBroker addOneTimeOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds anEventListener
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- Returns:
- See Also:
getVmWaitingList()
,addOnVmsCreatedListener(EventListener)
-
getVmDestructionDelayFunction
Function<Vm,Double> getVmDestructionDelayFunction()
Gets aFunction
which defines when an idle VM should be destroyed. The Function receives aVm
and returns the delay to wait (in seconds), after the VM becomes idle, to destroy it.- Returns:
- See Also:
DEF_VM_DESTRUCTION_DELAY
,Vm.getIdleInterval()
-
setVmDestructionDelayFunction
DatacenterBroker setVmDestructionDelayFunction(Function<Vm,Double> function)
Sets aFunction
to define when an idle VM should be destroyed. The Function receives aVm
and returns the delay to wait (in seconds), after the VM becomes idle, to destroy it.- Parameters:
function
- theFunction
to set (if null is given, it sets the default Function)- Returns:
- See Also:
DEF_VM_DESTRUCTION_DELAY
,Vm.getIdleInterval()
-
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
-
-