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 |
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 for
DatacenterBroker
objects. |
Modifier and Type | Method and Description |
---|---|
DatacenterBroker |
addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
Adds an
EventListener 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 the
waiting list ,
must run in a specific virtual machine. |
List<Cloudlet> |
destroyVm(Vm vm)
Destroys the passed VM.
|
List<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.
|
List<Cloudlet> |
getCloudletSubmittedList() |
<T extends Cloudlet> |
getCloudletWaitingList()
Gets the list of cloudlets submitted 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> |
getVmFailedList()
Gets a List of VMs submitted to the broker that have failed to be created inside
some Datacenter due to lack of suitable Hosts.
|
int |
getVmsNumber()
Gets the total number of VMs submitted to the broker, including created, waiting and failed VMs.
|
<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)
Gets a VM from the waiting list.
|
boolean |
isRetryFailedVms()
Checks if the broker has to retry allocating VMs
that couldn't be placed due to lack of suitable Hosts.
|
boolean |
isSelectClosestDatacenter()
Checks if the broker has to try selecting the closest
Datacenter
to place Vm s, based on their timezone. |
boolean |
isShutdownWhenIdle()
Checks if the broker must be shut down after becoming idle.
|
DatacenterBroker |
removeOnVmsCreatedListener(EventListener<? extends EventInfo> listener)
Removes an
EventListener 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
the
getVmDestructionDelayFunction() . |
void |
requestShutdownWhenIdle()
Requests the broker shutdown if it's idle.
|
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. |
DatacenterBroker |
setDatacenterMapper(BiFunction<Datacenter,Vm,Datacenter> datacenterMapper)
Sets the
BiFunction that selects and returns a Datacenter
to place submitted VMs. |
void |
setRetryFailedVms(boolean retryFailedVms)
Sets if the broker has to retry allocating VMs
that couldn't be placed due to lack of suitable Hosts.
|
DatacenterBroker |
setSelectClosestDatacenter(boolean select)
Defines if the broker has to try selecting the closest
Datacenter
to place Vm s, based on their timezone. |
DatacenterBroker |
setShutdownWhenIdle(boolean shutdownWhenIdle)
Indicates if the broker must be shut down after becoming idle.
|
DatacenterBroker |
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 |
setVmDestructionDelay(double delay)
Sets the delay after which an idle VM should be destroyed.
|
DatacenterBroker |
setVmDestructionDelayFunction(Function<Vm,Double> function)
Sets a
Function to define the delay after which an idle VM should be destroyed. |
DatacenterBroker |
setVmMapper(Function<Cloudlet,Vm> vmMapper)
Sets a
Function that maps a given Cloudlet to a Vm. |
DatacenterBroker |
submitCloudlet(Cloudlet cloudlet)
Submits a single
Cloudlet to the broker. |
DatacenterBroker |
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).
|
DatacenterBroker |
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.
|
DatacenterBroker |
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).
|
DatacenterBroker |
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.
|
DatacenterBroker |
submitVm(Vm vm)
|
DatacenterBroker |
submitVmList(List<? extends Vm> list)
Submits a list of
Vm or VmGroup that their creation inside a Host will be requested to some
Datacenter . |
DatacenterBroker |
submitVmList(List<? extends Vm> list,
double submissionDelay)
|
getShutdownTime, getSimulation, getStartTime, getState, isAlive, isFinished, isStarted, processEvent, run, schedule, schedule, schedule, schedule, schedule, schedule, schedule, setName, setSimulation, setState, shutdown, start
getId
compareTo
static final org.slf4j.Logger LOGGER
static final DatacenterBroker NULL
DatacenterBroker
objects.static final double DEF_VM_DESTRUCTION_DELAY
This is used as the 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)
index
- the index of the VM to get<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()
int getVmsNumber()
DatacenterBroker requestIdleVmDestruction(Vm vm)
getVmDestructionDelayFunction()
.
The request will be sent if the given delay function returns a value
greater than DEF_VM_DESTRUCTION_DELAY
.
Otherwise, it doesn't send the request, meaning the VM should not be destroyed according to a specific delay.vm
- the VM to destroygetVmDestructionDelayFunction()
void requestShutdownWhenIdle()
List<Cloudlet> destroyVm(Vm vm)
vm
- Virtual machine to be destroyed<T extends Vm> List<T> getVmCreatedList()
T
- the class of VMs inside the listgetVmExecList()
DatacenterBroker submitVm(Vm vm)
Vm
or VmGroup
to the broker.
When a VmGroup
is given, it will try to place all VMs inside it into the same Host.vm
- the Vm to be submittedVmGroup
DatacenterBroker submitVmList(List<? extends Vm> list)
Vm
or VmGroup
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 setDatacenterMapper(BiFunction)
.
When a list of VmGroup
is given, it will try to place all VMs from the same group into the same Host.
list
- the list of VMs to request the creationVmGroup
DatacenterBroker submitVmList(List<? extends Vm> list, double submissionDelay)
Vm
or VmGroup
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 the getVmWaitingList()
.
When a list of VmGroup
is given, it will try to place all VMs from the same group into the same Host.
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()
,
VmGroup
DatacenterBroker submitCloudlet(Cloudlet cloudlet)
Cloudlet
to the broker.cloudlet
- the Cloudlet to be submittedDatacenterBroker submitCloudletList(List<? extends Cloudlet> list)
getCloudletWaitingList()
.list
- the list of Cloudlets to request the creationsubmitCloudletList(java.util.List, double)
DatacenterBroker 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)
,
Cloudlet.getSubmissionDelay()
DatacenterBroker 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)
DatacenterBroker 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)
,
Cloudlet.getSubmissionDelay()
DatacenterBroker setDatacenterMapper(BiFunction<Datacenter,Vm,Datacenter> datacenterMapper)
BiFunction
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:
Datacenter.NULL
if no suitable Datacenter was foundWhen 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.
datacenterMapper
- the datacenterMapper to setDatacenterBroker 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 setDatacenterBroker 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
.DatacenterBroker setSelectClosestDatacenter(boolean select)
Datacenter
to place Vm
s, based on their timezone.
The default behaviour is to ignore Datacenter
s and Vm
s
timezones.select
- true to try selecting the closest Datacenter to be selected, false to ignore distanceboolean isSelectClosestDatacenter()
Datacenter
to place Vm
s, based on their timezone.
The default behaviour is to ignore Datacenter
s and Vm
s
timezones.setSelectClosestDatacenter(boolean)
List<Cloudlet> getCloudletCreatedList()
DatacenterBroker addOnVmsCreatedListener(EventListener<DatacenterBrokerEventInfo> listener)
EventListener
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:
listener
- the Listener that will be notifiedgetVmWaitingList()
DatacenterBroker removeOnVmsCreatedListener(EventListener<? extends EventInfo> listener)
EventListener
to stop it to be notified when
VMs in the waiting list are all created.listener
- the Listener that will be removedaddOnVmsCreatedListener(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.DEF_VM_DESTRUCTION_DELAY
,
AbstractMachine.getIdleInterval()
DatacenterBroker setVmDestructionDelay(double delay)
setVmDestructionDelayFunction(Function)
method.delay
- the time (in seconds) to wait before destroying idle VMsDEF_VM_DESTRUCTION_DELAY
,
AbstractMachine.getIdleInterval()
DatacenterBroker setVmDestructionDelayFunction(Function<Vm,Double> function)
Function
to define the delay after which an idle VM should be destroyed.
The Function must receive a Vm
and return the delay to wait (in seconds),
after the VM becomes idle, to destroy it.
By providing 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.
WARNING: The delay returned by the given function should be larger then the simulation minTimeBetweenEvents to ensure VMs are gracefully shutdown.
function
- the Function
to set (if null is given, no idle VM will be automatically destroyed)DEF_VM_DESTRUCTION_DELAY
,
AbstractMachine.getIdleInterval()
,
setVmDestructionDelay(double)
<T extends Vm> List<T> getVmFailedList()
retryFailedVms
is not enabled.T
- the class of VMs inside the listsetRetryFailedVms(boolean)}
boolean isRetryFailedVms()
void setRetryFailedVms(boolean retryFailedVms)
true
, the broker will retry to place the failed VM as soon as new VMs or Cloudlets
are submitted.false
, the VM will be just added to the getVmFailedList()
and the user simulation
have to deal with it.
If the VM has an OnCreationFailureListener
,
the VM will be notified about the failure.boolean isShutdownWhenIdle()
DatacenterBroker setShutdownWhenIdle(boolean shutdownWhenIdle)
Copyright © 2015–2021 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.