fenzo-core/src/main/java/com/netflix/fenzo/TaskScheduler.java
public SchedulingResult scheduleOnce(
            List<? extends TaskRequest> requests,
            List<VirtualMachineLease> newLeases) throws IllegalStateException {
        if (usingSchedulingService) {
            throw new IllegalStateException(usingSchedSvcMesg);
        }
        final Iterator<? extends TaskRequest> iterator =
                requests != null ?
                        requests.iterator() :
                        Collections.<TaskRequest>emptyIterator();
        TaskIterator taskIterator = () -> {
            if (iterator.hasNext()) {
                return Assignable.success(iterator.next());
            }
            return null;
        };
        return scheduleOnce(taskIterator, newLeases);
    }
public SchedulingResult scheduleOnce(
            List<? extends TaskRequest> requests,
            List<VirtualMachineLease> newLeases) throws IllegalStateException {
        if (usingSchedulingService) {
            throw new IllegalStateException(usingSchedSvcMesg);
        }
        final Iterator<? extends TaskRequest> iterator =
                requests != null ?
                        requests.iterator() :
                        Collections.<TaskRequest>emptyIterator();
        TaskIterator taskIterator = () -> {
            if (iterator.hasNext()) {
                return Assignable.success(iterator.next());
            }
            return null;
        };
        return scheduleOnce(taskIterator, newLeases);
    }
Schedule a list of task requests by using any newly-added resource leases in addition to any
previously-unused leases. This is the main scheduling method that attempts to assign resources to task
requests. Resource leases are associated with a host name. A host can have zero or more leases. Leases
that the scheduler does not use in this scheduling run it stores for later use until they expire.
<p>
You cannot add a lease object with an Id equal to that of a stored lease object; {@code scheduleOnce()}
will throw an {@code IllegalStateException}. Upon throwing this exception, if you provided multiple
leases in the {@code newLeases} argument, the state of internally maintained list of unused leases will
be in an indeterminate state - some of the leases may have been successfully added.
<p>
The task scheduler rejects any expired leases before scheduling begins. Then, it combines all leases of a
host to determine the total available resources on the host. The scheduler then tries each task request,
in the order that they appear in the given list, for assignment against the available hosts until
successful. For each task the scheduler returns either a successful assignment result, or, a set of
assignment failures.
<p>
After the scheduler evaluates all assignments, it will reject remaining leases if they are unused and
their offer time is further in the past than lease expiration interval. This prevents the scheduler from
hoarding leases. If you provided an autoscaler, the scheduler then launches autoscale evaluation to run
asynchronously, which runs each registered autoscale rule based on its policy.
<p>
The successful assignments contain hosts to which tasks have been successfully assigned and the offers for that
host that were used for the assignments. Fenzo removes those offers from its internal state. Normally, you
would use those offers to launch the tasks. For any reason if you do not launch those tasks, you must either
reject the offers to Mesos, or, re-add them to Fenzo with the next call to {@link #scheduleOnce(List, List)}.
Otherwise, those offers would be "leaked out".
<p>
Unexpected exceptions may arise during scheduling, for example, due to uncaught exceptions in user provided
plugins. The scheduling routine stops upon catching any unexpected exceptions. These exceptions are surfaced to
you in one or both of two ways.
<UL>
<li>The returned result object will contain the exceptions encountered in
{@link SchedulingResult#getExceptions()}. In this case, no assignments would have been made.</li>
<li>This method may throw {@code IllegalStateException} with its cause set to the uncaught exception. In this
case the internal state of Fenzo will be undefined.</li>
</UL>
If there are exceptions, the internal state of Fenzo may be corrupt with no way to undo any partial effects.

@param requests  a list of task requests to match with resources, in their given order
@param newLeases new resource leases from hosts that the scheduler can use along with any previously
ununsed leases
@return a {@link SchedulingResult} object that contains a task assignment results map and other summaries
@throws IllegalStateException if you call this method concurrently, or, if you try to add an existing lease
again, or, if there was unexpected exception during the scheduling iteration, or, if using
{@link TaskSchedulingService}, which will instead invoke scheduling from within. Unexpected exceptions
can arise from uncaught exceptions in user defined plugins. It is also thrown if the scheduler has been shutdown
via the {@link #shutdown()} method.