// IMPORTANT: To prevent leaks of cluster resources, we need to make sure that slots are returned
// in all cases where the deployment failed. we use many try {} finally {} clauses to assure that
if (queued) {
SlotAllocationFuture future = scheduler.scheduleQueued(toSchedule);
future.setFutureAction(new SlotAllocationFutureAction() {
@Override
public void slotAllocated(AllocatedSlot slot) {
try {
deployToSlot(slot);
}