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.
SimEntity.State
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_VM_DESTRUCTION_DELAY
A default delay value to indicate that any VM should NOT be
immediately destroyed after it becomes idle.
|
static DatacenterBroker |
NULL
An attribute that implements the Null Object Design Pattern for
DatacenterBroker
objects. |
Modifier and Type | Method and Description |
---|---|
DatacenterBroker |
addOneTimeOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds an
EventListener that will be notified just once
when VMs in the waiting list are all created. |
DatacenterBroker |
addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds an
EventListener 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 the
waiting list ,
must run in a specific virtual machine. |
Set<Cloudlet> |
getCloudletCreatedList()
Gets a read-only list of cloudlets created inside some Vm.
|
<T extends Cloudlet> |
getCloudletFinishedList()
Gets a copy of the list of cloudlets that have finished executing,
to avoid the original list to be changed.
|
<T extends Cloudlet> |
getCloudletWaitingList()
Gets the list of cloudlets submmited to the broker that are waiting to be created inside
some Vm yet.
|
<T extends Vm> |
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 a
Function which defines when an idle VM should be destroyed. |
<T extends Vm> |
getVmExecList()
Gets the list of VMs in execution, if they are running Cloudlets or not.
|
<T extends Vm> |
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 a
Comparator that will be used to sort every list
of submitted Cloudlets before mapping each Cloudlet to a Vm. |
void |
setDatacenterSupplier(Supplier<Datacenter> datacenterSupplier)
Sets the
Supplier that selects and returns a Datacenter
to place submitted VMs. |
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. |
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. |
DatacenterBroker |
setVmDestructionDelayFunction(Function<Vm,Double> function)
Sets a
Function to define when an idle VM should be destroyed. |
void |
setVmMapper(Function<Cloudlet,Vm> vmMapper)
Sets a
Function that maps a given Cloudlet to a Vm. |
void |
submitCloudlet(Cloudlet cloudlet)
Submits a single
Cloudlet 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 single
Vm 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 some
Datacenter . |
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.
|
getSimulation, isStarted, println, println, processEvent, run, schedule, setLog, setName, setSimulation, setState, shutdownEntity, start
getId
compareTo
static final DatacenterBroker NULL
DatacenterBroker
objects.static final double DEFAULT_VM_DESTRUCTION_DELAY
This is used as the default value returned by the getVmDestructionDelayFunction()
if a Function
is not set.
boolean bindCloudletToVm(Cloudlet cloudlet, Vm vm)
waiting list
,
must run in a specific virtual machine.cloudlet
- the cloudlet to be bind to a given Vmvm
- the vm to bind the Cloudlet to<T extends Cloudlet> List<T> getCloudletWaitingList()
T
- the class of Cloudlets inside the list<T extends Cloudlet> List<T> getCloudletFinishedList()
T
- the class of Cloudlets inside the listVm getWaitingVm(int index)
<T extends Vm> List<T> getVmWaitingList()
T
- the class of VMs inside the list<T extends Vm> List<T> getVmExecList()
T
- the class of VMs inside the listgetVmCreatedList()
<T extends Vm> List<T> getVmCreatedList()
T
- the class of VMs inside the listgetVmExecList()
void submitVm(Vm vm)
Vm
to the broker.vm
- the Vm to be submittedvoid submitCloudlet(Cloudlet cloudlet)
Cloudlet
to the broker.cloudlet
- the Cloudlet to be submittedvoid submitCloudletList(List<? extends Cloudlet> list)
getCloudletWaitingList()
.list
- the list of Cloudlets to request the creationsubmitCloudletList(java.util.List, double)
void submitCloudletList(List<? extends Cloudlet> list, double submissionDelay)
getCloudletWaitingList()
,
setting their submission delay to the specified value.list
- the list of Cloudlets to request the creationsubmissionDelay
- the delay the broker has to include when requesting the creation of CloudletssubmitCloudletList(java.util.List)
,
Delayable.getSubmissionDelay()
void submitCloudletList(List<? extends Cloudlet> list, Vm vm)
getCloudletWaitingList()
.list
- the list of Cloudlets to request the creationvm
- the VM to which all Cloudlets will be bound tosubmitCloudletList(java.util.List, double)
void submitCloudletList(List<? extends Cloudlet> list, Vm vm, double submissionDelay)
getCloudletWaitingList()
,
setting their submission delay to the specified value.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 CloudletssubmitCloudletList(java.util.List)
,
Delayable.getSubmissionDelay()
void submitVmList(List<? extends Vm> list)
Datacenter
. The Datacenter that will be chosen to place a VM is
determined by the setDatacenterSupplier(Supplier)
.list
- the list of VMs to request the creationvoid submitVmList(List<? extends Vm> list, double submissionDelay)
getVmWaitingList()
,
setting their submission delay to the specified value.list
- the list of VMs to request the creationsubmissionDelay
- the delay the broker has to include when requesting the creation of VMssubmitVmList(java.util.List)
,
Delayable.getSubmissionDelay()
boolean isThereWaitingCloudlets()
void setDatacenterSupplier(Supplier<Datacenter> datacenterSupplier)
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.
datacenterSupplier
- the datacenterSupplier to setvoid setFallbackDatacenterSupplier(Supplier<Datacenter> fallbackDatacenterSupplier)
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.
fallbackDatacenterSupplier
- the fallbackDatacenterSupplier to setvoid setVmComparator(Comparator<Vm> comparator)
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.comparator
- the VM Comparator to setvoid setCloudletComparator(Comparator<Cloudlet> comparator)
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.comparator
- the Cloudlet Comparator to setvoid setVmMapper(Function<Cloudlet,Vm> vmMapper)
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.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
.Set<Cloudlet> getCloudletCreatedList()
DatacenterBroker addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
EventListener
that will be notified every time
VMs in the waiting list are all created.
Events are fired according to the following conditions:
listener
- the Listener that will be notifiedgetVmWaitingList()
,
addOneTimeOnVmsCreatedListener(EventListener)
DatacenterBroker addOneTimeOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
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.
listener
- the Listener that will be notifiedgetVmWaitingList()
,
addOnVmsCreatedListener(EventListener)
Function<Vm,Double> getVmDestructionDelayFunction()
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.DEFAULT_VM_DESTRUCTION_DELAY
,
Vm.getIdleInterval()
DatacenterBroker setVmDestructionDelayFunction(Function<Vm,Double> function)
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.function
- the Function
to set (if null is given, it sets the default Function)DEFAULT_VM_DESTRUCTION_DELAY
,
Vm.getIdleInterval()
Copyright © 2015–2018 Systems, Security and Image Communication Lab - Instituto de Telecomunicações (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO). All rights reserved.