提交阶段时Spark如何避免多线程冲突

时间:2018-10-15 17:22:55

标签: apache-spark

我试图编写一个可以处理DAG计划的程序,但遇到一个问题,当两个孩子同时成功执行时,可能会重复执行父进程。因此,我提到了Spark的设计,但没有找到Spark处理这种​​情况的地方。

/** Submits stage, but first recursively submits any missing parents. */
  private def submitStage(stage: Stage) {
    val jobId = activeJobForStage(stage)
    if (jobId.isDefined) {
      logDebug("submitStage(" + stage + ")")
      if (!waitingStages(stage) && !runningStages(stage) && !failedStages(stage)) {
        val missing = getMissingParentStages(stage).sortBy(_.id)
        logDebug("missing: " + missing)
        if (missing.isEmpty) {
          logInfo("Submitting " + stage + " (" + stage.rdd + "), which has no missing parents")
          submitMissingTasks(stage, jobId.get)
        } else {
          for (parent <- missing) {
            submitStage(parent)
          }
          waitingStages += stage
        }
      }
    } else {
      abortStage(stage, "No active job for stage " + stage.id, None)
    }
  }

我错过了什么吗?

0 个答案:

没有答案