Skip to content

Commit

Permalink
Use pluggable clock in DAGSheduler #SPARK-2031
Browse files Browse the repository at this point in the history
DAGScheduler supports pluggable clock like what TaskSetManager does.

Author: CrazyJvm <[email protected]>

Closes apache#976 from CrazyJvm/clock and squashes the following commits:

6779a4c [CrazyJvm] Use pluggable clock in DAGSheduler
  • Loading branch information
CrazyJvm authored and pdeyhim committed Jun 25, 2014
1 parent 2ea7ce7 commit f052dff
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.apache.spark.executor.TaskMetrics
import org.apache.spark.partial.{ApproximateActionListener, ApproximateEvaluator, PartialResult}
import org.apache.spark.rdd.RDD
import org.apache.spark.storage.{BlockId, BlockManager, BlockManagerMaster, RDDBlockId}
import org.apache.spark.util.Utils
import org.apache.spark.util.{SystemClock, Clock, Utils}

/**
* The high-level scheduling layer that implements stage-oriented scheduling. It computes a DAG of
Expand All @@ -61,7 +61,8 @@ class DAGScheduler(
listenerBus: LiveListenerBus,
mapOutputTracker: MapOutputTrackerMaster,
blockManagerMaster: BlockManagerMaster,
env: SparkEnv)
env: SparkEnv,
clock: Clock = SystemClock)
extends Logging {

import DAGScheduler._
Expand Down Expand Up @@ -781,7 +782,7 @@ class DAGScheduler(
logDebug("New pending tasks: " + myPending)
taskScheduler.submitTasks(
new TaskSet(tasks.toArray, stage.id, stage.newAttemptId(), stage.jobId, properties))
stageToInfos(stage).submissionTime = Some(System.currentTimeMillis())
stageToInfos(stage).submissionTime = Some(clock.getTime())
} else {
logDebug("Stage " + stage + " is actually done; %b %d %d".format(
stage.isAvailable, stage.numAvailableOutputs, stage.numPartitions))
Expand All @@ -807,11 +808,11 @@ class DAGScheduler(

def markStageAsFinished(stage: Stage) = {
val serviceTime = stageToInfos(stage).submissionTime match {
case Some(t) => "%.03f".format((System.currentTimeMillis() - t) / 1000.0)
case Some(t) => "%.03f".format((clock.getTime() - t) / 1000.0)
case _ => "Unknown"
}
logInfo("%s (%s) finished in %s s".format(stage, stage.name, serviceTime))
stageToInfos(stage).completionTime = Some(System.currentTimeMillis())
stageToInfos(stage).completionTime = Some(clock.getTime())
listenerBus.post(SparkListenerStageCompleted(stageToInfos(stage)))
runningStages -= stage
}
Expand Down Expand Up @@ -1015,7 +1016,7 @@ class DAGScheduler(
return
}
val dependentStages = resultStageToJob.keys.filter(x => stageDependsOn(x, failedStage)).toSeq
stageToInfos(failedStage).completionTime = Some(System.currentTimeMillis())
stageToInfos(failedStage).completionTime = Some(clock.getTime())
for (resultStage <- dependentStages) {
val job = resultStageToJob(resultStage)
failJobAndIndependentStages(job, s"Job aborted due to stage failure: $reason",
Expand Down

0 comments on commit f052dff

Please sign in to comment.