Launch tasks

@param tasks list of LaunchableTask
337376
protected void launchTasks(List<LaunchableTask> tasks) {
    // Group the tasks by offer
    Map<Protos.Offer, List<LaunchableTask>> tasksGroupByOffer = new HashMap<>();
    for (LaunchableTask task : tasks) {
      List<LaunchableTask> subTasks = tasksGroupByOffer.get(task.offer);
      if (subTasks == null) {
        subTasks = new LinkedList<>();
      }
      subTasks.add(task);
      tasksGroupByOffer.put(task.offer, subTasks);
    }

    // Construct the Mesos TaskInfo to launch
    for (Map.Entry<Protos.Offer, List<LaunchableTask>> kv : tasksGroupByOffer.entrySet()) {
      // We would launch taks for the same offer at one shot
      Protos.Offer offer = kv.getKey();
      List<LaunchableTask> subTasks = kv.getValue();

      List<Protos.TaskInfo> mesosTasks = new LinkedList<>();
      for (LaunchableTask task : subTasks) {
        Protos.TaskInfo pTask = task.constructMesosTaskInfo(heronConfig, heronRuntime);
        mesosTasks.add(pTask);
      }

      LOG.info("Launching tasks from offer: " + offer + " with tasks: " + mesosTasks);

      // Launch the tasks for the same offer
      Protos.Status status =
          driver.launchTasks(Arrays.asList(new Protos.OfferID[]{offer.getId()}),
              mesosTasks);

      if (status == Protos.Status.DRIVER_RUNNING) {
        LOG.info(String.format("Tasks launched, status: '%s'", status));

      } else {
        LOG.severe("Other status returned: " + status);

        // Handled failed tasks
        for (LaunchableTask task : tasks) {
          handleMesosFailure(task.taskId);
          // No need to decline the offers; mesos master already reclaim them
        }
      }
    }
  }
807659
void addTaskToChain(Task[] tasks, Task task, int index) {
        task.setNext(tasks[index]);
        tasks[index] = task;
    }
226484
private void startTask(ApplicationDefinition appDef, Task task, TaskRecord taskRecord) {
        try {
            task.setParams(m_localHost, taskRecord);
            m_executor.execute(task);
        } catch (Exception e) {
            m_logger.error("Failed to start task '" + task.getTaskID() + "'", e);
        }
    }
1370930
@SuppressWarnings("unchecked")
    @TargetApi(VERSION_CODES.HONEYCOMB)
    public static <T> void execute(AsyncTask<T, ?, ?> task, T... args) {
        if (Build.VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) {
            task.execute(args);
        } else {
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args);
        }
    }
960101
public void setExportTasks(java.util.Collection<ExportTask> exportTasks) {
        if (exportTasks == null) {
            this.exportTasks = null;
            return;
        }

        this.exportTasks = new com.amazonaws.internal.SdkInternalList<ExportTask>(exportTasks);
    }
459570
public void setLaunchTemplates(java.util.Collection<LaunchTemplate> launchTemplates) {
        if (launchTemplates == null) {
            this.launchTemplates = null;
            return;
        }

        this.launchTemplates = new com.amazonaws.internal.SdkInternalList<LaunchTemplate>(launchTemplates);
    }
1371557
@Nonnull
    public static <T> List<TtlCallable<T>> gets(@Nullable Collection<? extends Callable<T>> tasks) {
        return gets(tasks, false, false);
    }
908246
public void setTaskSets(java.util.Collection<String> taskSets) {
        if (taskSets == null) {
            this.taskSets = null;
            return;
        }

        this.taskSets = new com.amazonaws.internal.SdkInternalList<String>(taskSets);
    }
761740
<TInput, TOutput> void launchTasklet(final Tasklet<TInput, TOutput> tasklet) {
    assert !runningTasklets.containsKey(tasklet.getId());
    runningTasklets.put(tasklet.getId(), tasklet);

    if (tasklet.getAggregateFunctionId().isPresent()) {
      // function is aggregateable.
      final TaskletAggregateExecutionRequest<TInput> taskletAggregateExecutionRequest =
          new TaskletAggregateExecutionRequest<>(tasklet.getId(), tasklet.getAggregateFunctionId().get(),
              tasklet.getInput());
      vortexRequestor.sendAsync(reefTask, taskletAggregateExecutionRequest);
    } else {
      // function is not aggregateable.
      final TaskletExecutionRequest<TInput, TOutput> taskletExecutionRequest
          = new TaskletExecutionRequest<>(tasklet.getId(), tasklet.getUserFunction(), tasklet.getInput());
      vortexRequestor.sendAsync(reefTask, taskletExecutionRequest);
    }
  }
897609
public FileDownloadQueueSet downloadTogether(List<BaseDownloadTask> tasks) {
        this.isSerial = false;
        this.tasks = new BaseDownloadTask[tasks.size()];
        tasks.toArray(this.tasks);

        return this;

    }
584751
void runTasks(Task[] tasks, int maxTaskIndex) {
        for (int i = 0; i <= maxTaskIndex; i++) {
            runTasksInChain(tasks[i]);
            tasks[i] = null;
        }
    }
757762
public void startSnapshotWithTargets(Collection<SnapshotDataTarget> targets, long now)
    {
        // TRAIL [SnapSave:9] 5 [all SP] Start snapshot by putting task into the site queue.
        //Basically asserts that there are no tasks with null targets at this point
        //getTarget checks and crashes
        for (SnapshotTableTask t : m_snapshotTableTasks.values()) {
            t.getTarget();
        }

        ArrayList<SnapshotDataTarget> targetsToClose = Lists.newArrayList();
        for (final SnapshotDataTarget target : targets) {
            if (target.needsFinalClose()) {
                targetsToClose.add(target);
            }
        }
        m_snapshotTargets = targetsToClose;

        // Queue the first snapshot task
        VoltDB.instance().schedulePriorityWork(
                new Runnable() {
                    @Override
                    public void run()
                    {
                        m_siteTaskerQueue.offer(new SnapshotTask());
                    }
                },
                (m_quietUntil + (5 * m_snapshotPriority) - now),
                0,
                TimeUnit.MILLISECONDS);
        m_quietUntil += 5 * m_snapshotPriority;
    }
327800
public void run(Collection<Runnable> tasks) {
        // Create a semphore that the wrapped runnables will execute
        int numTasks = tasks.size();
        CountDownLatch latch = new CountDownLatch(numTasks);
        for (Runnable r : tasks) {
            if (r == null)
                throw new NullPointerException("Cannot run null tasks");
            workQueue.offer(new CountingRunnable(r, latch));
        }
        try {
            // Wait until all the tasks have finished
            latch.await();
        }
        catch (InterruptedException ie) {
            throw new IllegalStateException("Not all tasks finished", ie);
        }
    }
548783
public static void cancelChainedTasks(List<ChainedDriver<?, ?>> tasks) {
		for (int i = 0; i < tasks.size(); i++) {
			try {
				tasks.get(i).cancelTask();
			} catch (Throwable t) {
				// do nothing
			}
		}
	}
89449
public static void waitFinished(Collection<? extends Task<?,?>> tasks) throws Exception {
		for (Task<?,?> t : tasks) {
			t.getOutput().blockThrow(0);
		}
	}
405637
public void setTasks(java.util.Collection<ImportTask> tasks) {
        if (tasks == null) {
            this.tasks = null;
            return;
        }

        this.tasks = new java.util.ArrayList<ImportTask>(tasks);
    }
683053
def initiate_tasks(self):
        
        self.tasks_classes = TaskLoader().load_tasks(
            paths=self.configuration[Configuration.ALGORITHM][Configuration.TASKS][Configuration.PATHS])