Github user markhamstra commented on the pull request:

    https://github.com/apache/spark/pull/186#issuecomment-40410340
  
    I'll look at it some more tmorrow, but this needs to be rebased to current 
master -- e.g.,
    
    diff --git 
a/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala 
b/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
    index e637ddc..9657cbf 100644
    --- a/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
    +++ b/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
    @@ -482,12 +482,19 @@ class DAGScheduler(
     
       private[scheduler] def doCancelAllJobs() {
         // Cancel all running jobs.
    -    runningStages.map(_.jobId).foreach(handleJobCancellation)
    +    runningStages.map(_.jobId).foreach(handleJobCancellation(_, "as part 
of cancellation of all jobs"))
         activeJobs.clear() // These should already be empty by this point,
         jobIdToActiveJob.clear() // but just in case we lost track of some 
jobs...
       }
     
       /**
    +   * Cancel all jobs associated with a running or scheduled stage.
    +   */
    +  def cancelStage(stageId: Int) {
    +    eventProcessActor ! StageCancelled(stageId)
    +  }
    +
    +  /**
        * Resubmit any failed stages. Ordinarily called after a small amount of 
time has passed since
        * the last fetch failure.
        */
    @@ -849,11 +856,23 @@ class DAGScheduler(
         }
       }
     
    -  private[scheduler] def handleJobCancellation(jobId: Int) {
    +  private[scheduler] def handleStageCancellation(stageId: Int) {
    +    if (stageIdToJobIds.contains(stageId)) {
    +      val jobsThatUseStage: Array[Int] = stageIdToJobIds(stageId).toArray
    +      jobsThatUseStage.foreach(jobId => {
    +        handleJobCancellation(jobId, "because Stage %s was 
cancelled".format(stageId))
    +      })
    +    } else {
    +      logInfo("No active jobs to kill for Stage " + stageId)
    +    }
    +  }
    +
    +  private[scheduler] def handleJobCancellation(jobId: Int, reason: String 
= "") {
         if (!jobIdToStageIds.contains(jobId)) {
           logDebug("Trying to cancel unregistered job " + jobId)
         } else {
    -      failJobAndIndependentStages(jobIdToActiveJob(jobId), s"Job $jobId 
cancelled", None)
    +      failJobAndIndependentStages(jobIdToActiveJob(jobId),
    +        s"Job $jobId cancelled $reason", None)
         }
       }
     
    @@ -1060,6 +1079,9 @@ private[scheduler] class 
DAGSchedulerEventProcessActor(dagScheduler: DAGSchedule
             dagScheduler.submitStage(finalStage)
           }
     
    +    case StageCancelled(stageId) =>
    +      dagScheduler.handleStageCancellation(stageId)
    +
         case JobCancelled(jobId) =>
           dagScheduler.handleJobCancellation(jobId)
     
    @@ -1069,7 +1091,7 @@ private[scheduler] class 
DAGSchedulerEventProcessActor(dagScheduler: DAGSchedule
           val activeInGroup = dagScheduler.activeJobs.filter(activeJob =>
             groupId == 
activeJob.properties.get(SparkContext.SPARK_JOB_GROUP_ID))
           val jobIds = activeInGroup.map(_.jobId)
    -      jobIds.foreach(dagScheduler.handleJobCancellation)
    +      jobIds.foreach(dagScheduler.handleJobCancellation(_, s"as part of 
cancelled job group %groupId"))
     
         case AllJobsCancelled =>
           dagScheduler.doCancelAllJobs()


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to