Interface DatacenterBroker
- All Superinterfaces:
java.lang.Cloneable
,java.lang.Comparable<SimEntity>
,Identifiable
,Nameable
,java.lang.Runnable
,SimEntity
- All Known Implementing Classes:
DatacenterBrokerAbstract
,DatacenterBrokerBestFit
,DatacenterBrokerFirstFit
,DatacenterBrokerHeuristic
,DatacenterBrokerSimple
public interface DatacenterBroker extends SimEntity
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
Modifier and Type Method Description DatacenterBroker
addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds anEventListener
that will be notified every time VMs in the waiting list are all created (placed) in some Host.boolean
bindCloudletToVm(Cloudlet cloudlet, Vm vm)
Specifies that an already submitted cloudlet, which is in thewaiting list
, must run in a specific virtual machine.java.util.List<Cloudlet>
destroyVm(Vm vm)
Destroys the passed VM.java.util.List<Cloudlet>
getCloudletCreatedList()
Gets a read-only list of cloudlets created inside some Vm.<T extends Cloudlet>
java.util.List<T>getCloudletFinishedList()
Gets a copy of the list of cloudlets that have finished executing, to avoid the original list to be changed.java.util.List<Cloudlet>
getCloudletSubmittedList()
<T extends Cloudlet>
java.util.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>
java.util.List<T>getVmCreatedList()
Gets the list of all VMs created so far, independently if they are running yet or were already destroyed.java.util.function.Function<Vm,java.lang.Double>
getVmDestructionDelayFunction()
Gets aFunction
which defines when an idle VM should be destroyed.<T extends Vm>
java.util.List<T>getVmExecList()
Gets the list of VMs in execution, if they are running Cloudlets or not.<T extends Vm>
java.util.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)
Gets a VM from the waiting list.boolean
isSelectClosestDatacenter()
Checks if the broker has to try selecting the closestDatacenter
to placeVm
s, based on their timezone.DatacenterBroker
removeOnVmsCreatedListener(EventListener<? extends EventInfo> listener)
Removes anEventListener
to stop it to be notified when VMs in the waiting list are all created.DatacenterBroker
requestIdleVmDestruction(Vm vm)
Checks if a VM is idle VM and request it to be destroyed at the time defined by thegetVmDestructionDelayFunction()
.void
setCloudletComparator(java.util.Comparator<Cloudlet> comparator)
Sets aComparator
that will be used to sort every list of submitted Cloudlets before mapping each Cloudlet to a Vm.DatacenterBroker
setDatacenterMapper(java.util.function.BiFunction<Datacenter,Vm,Datacenter> datacenterMapper)
Sets theBiFunction
that selects and returns a Datacenter to place submitted VMs.DatacenterBroker
setSelectClosestDatacenter(boolean select)
Defines if the broker has to try selecting the closestDatacenter
to placeVm
s, based on their timezone.DatacenterBroker
setVmComparator(java.util.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
setVmDestructionDelay(double delay)
Sets the delay after which an idle VM should be destroyed.DatacenterBroker
setVmDestructionDelayFunction(java.util.function.Function<Vm,java.lang.Double> function)
Sets aFunction
to define the delay after which an idle VM should be destroyed.DatacenterBroker
setVmMapper(java.util.function.Function<Cloudlet,Vm> vmMapper)
Sets aFunction
that maps a given Cloudlet to a Vm.DatacenterBroker
submitCloudlet(Cloudlet cloudlet)
Submits a singleCloudlet
to the broker.DatacenterBroker
submitCloudletList(java.util.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).DatacenterBroker
submitCloudletList(java.util.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.DatacenterBroker
submitCloudletList(java.util.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).DatacenterBroker
submitCloudletList(java.util.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.DatacenterBroker
submitVm(Vm vm)
DatacenterBroker
submitVmList(java.util.List<? extends Vm> list)
Submits a list ofVm
orVmGroup
that their creation inside a Host will be requested to someDatacenter
.DatacenterBroker
submitVmList(java.util.List<? extends Vm> list, double submissionDelay)
Methods inherited from interface org.cloudbus.cloudsim.core.SimEntity
getSimulation, getState, isAlive, isFinished, isStarted, processEvent, run, schedule, schedule, schedule, schedule, schedule, schedule, schedule, setName, setSimulation, setState, shutdownEntity, start
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER -
NULL
An attribute that implements the Null Object Design Pattern forDatacenterBroker
objects. -
DEF_VM_DESTRUCTION_DELAY
static final double DEF_VM_DESTRUCTION_DELAYA default delay value to indicate that NO VM should be immediately destroyed after becoming idle.This is used as the value returned by the
getVmDestructionDelayFunction()
if aFunction
is not set.
-
-
Method Details
-
bindCloudletToVm
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)
-
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
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
Gets a VM from the waiting list.- Parameters:
index
- the index of the VM to get- Returns:
- the waiting VM
-
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
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()
-
requestIdleVmDestruction
Checks if a VM is idle VM and request it to be destroyed at the time defined by thegetVmDestructionDelayFunction()
. The request will be sent if the given delay function returns a value greater thanDEF_VM_DESTRUCTION_DELAY
. Otherwise, it doesn't send the request, meaning the VM should not be destroyed according to a specific delay.- Parameters:
vm
- the VM to destroy- Returns:
- See Also:
getVmDestructionDelayFunction()
-
destroyVm
Destroys the passed VM.- Parameters:
vm
- Virtual machine to be destroyed- Returns:
- Cloudlets which were being queued or running on the target VM. All have reset state.
-
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
Submits a singleVm
orVmGroup
to the broker. When aVmGroup
is given, it will try to place all VMs inside it into the same Host.- Parameters:
vm
- the Vm to be submitted- Returns:
- See Also:
VmGroup
-
submitVmList
Submits a list ofVm
orVmGroup
that their creation inside a Host will be requested to someDatacenter
. The Datacenter that will be chosen to place a VM is determined by thesetDatacenterMapper(BiFunction)
.When a list of
VmGroup
is given, it will try to place all VMs from the same group into the same Host.- Parameters:
list
- the list of VMs to request the creation- Returns:
- See Also:
VmGroup
-
submitVmList
Submits a list ofVm
orVmGroup
to 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()
.When a list of
VmGroup
is given, it will try to place all VMs from the same group into the same Host.- Parameters:
list
- the list of VMs to request the creationsubmissionDelay
- the delay the broker has to include when requesting the creation of VMs- Returns:
- See Also:
submitVmList(java.util.List)
,Delayable.getSubmissionDelay()
,VmGroup
-
submitCloudlet
Submits a singleCloudlet
to the broker.- Parameters:
cloudlet
- the Cloudlet to be submitted- Returns:
-
submitCloudletList
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- Returns:
- See Also:
submitCloudletList(java.util.List, double)
-
submitCloudletList
DatacenterBroker submitCloudletList(java.util.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- Returns:
- See Also:
submitCloudletList(java.util.List)
,Cloudlet.getSubmissionDelay()
-
submitCloudletList
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- Returns:
- See Also:
submitCloudletList(java.util.List, double)
-
submitCloudletList
DatacenterBroker submitCloudletList(java.util.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- Returns:
- See Also:
submitCloudletList(java.util.List)
,Cloudlet.getSubmissionDelay()
-
setDatacenterMapper
DatacenterBroker setDatacenterMapper(java.util.function.BiFunction<Datacenter,Vm,Datacenter> datacenterMapper)Sets theBiFunction
that selects and returns a Datacenter to place submitted VMs.It defines the policy to select a Datacenter to host a VM that is waiting to be created. It receives as parameter the last selected Datacenter, the VM trying to be created and should return:
- the Datacenter for the next VMs in the waiting list
- or
Datacenter.NULL
if no suitable Datacenter was found
When there are VMs in the waiting list, the provided Function will be called. If it receives
Datacenter.NULL
it indicates that a Datacenter was never selected to place VMs or the previous selected Datacenter has not enough resources for all the waiting VMs. The Function you provide here should consider that when returning the Datacenter where the creation of waiting VMs will be tried.- Parameters:
datacenterMapper
- the datacenterMapper to set- Returns:
-
setVmComparator
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- Returns:
-
setCloudletComparator
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
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
.- Returns:
-
setSelectClosestDatacenter
Defines if the broker has to try selecting the closestDatacenter
to placeVm
s, based on their timezone. The default behaviour is to ignoreDatacenter
s andVm
s timezones.- Parameters:
select
- true to try selecting the closest Datacenter to be selected, false to ignore distance- Returns:
-
isSelectClosestDatacenter
boolean isSelectClosestDatacenter()Checks if the broker has to try selecting the closestDatacenter
to placeVm
s, based on their timezone. The default behaviour is to ignoreDatacenter
s andVm
s timezones.- Returns:
- true if the closest Datacenter selection is enabled, false if it's disabled
- See Also:
setSelectClosestDatacenter(boolean)
-
getCloudletCreatedList
java.util.List<Cloudlet> getCloudletCreatedList()Gets a read-only list of cloudlets created inside some Vm.- Returns:
- the list of created Cloudlets
-
addOnVmsCreatedListener
Adds anEventListener
that will be notified every time VMs in the waiting list are all created (placed) in some Host.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, in the entire simulation execution time, for every registered Listener;
- 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()
-
removeOnVmsCreatedListener
Removes anEventListener
to stop it to be notified when VMs in the waiting list are all created.- Parameters:
listener
- the Listener that will be removed- Returns:
- See Also:
addOnVmsCreatedListener(EventListener)
-
getVmDestructionDelayFunction
java.util.function.Function<Vm,java.lang.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
,Machine.getIdleInterval()
-
setVmDestructionDelay
Sets the delay after which an idle VM should be destroyed. Using such a method defines the same delay for any VM that becomes idle. If you need to define different delays for distinct VMs use thesetVmDestructionDelayFunction(Function)
method.- Parameters:
delay
- the time (in seconds) to wait before destroying idle VMs- Returns:
- See Also:
DEF_VM_DESTRUCTION_DELAY
,Machine.getIdleInterval()
-
setVmDestructionDelayFunction
DatacenterBroker setVmDestructionDelayFunction(java.util.function.Function<Vm,java.lang.Double> function)Sets aFunction
to define the delay after which an idle VM should be destroyed. The Function must receive aVm
and return the delay to wait (in seconds), after the VM becomes idle, to destroy it.By defining a
Function
to define when idle VMs should be destroyed enables you to define different delays for every VM that becomes idle, according to desired conditions.- Parameters:
function
- theFunction
to set (if null is given, no idle VM will be automatically destroyed)- Returns:
- See Also:
DEF_VM_DESTRUCTION_DELAY
,Machine.getIdleInterval()
,setVmDestructionDelay(double)
-
getCloudletSubmittedList
java.util.List<Cloudlet> getCloudletSubmittedList()
-