Interface DatacenterBroker

    • Method Detail

      • 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)
        Precondition:
        cloudletId > 0, id > 0
        Postcondition:
        $none
      • getCloudletWaitingList

        <T extends CloudletList<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 CloudletList<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 VmList<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 VmList<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 VmList<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 single Vm to the broker.
        Parameters:
        vm - the Vm to be submitted
      • 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)
        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 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), 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 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)
        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 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), 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 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
        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 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), 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 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
      • 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
      • 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.
      • 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 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
        Returns:
        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
        Returns:
        See Also:
        getVmWaitingList(), addOnVmsCreatedListener(EventListener)
      • 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
      • getCloudletSubmittedList

        List<Cloudlet> getCloudletSubmittedList()