1. 程式人生 > >Spark源碼剖析——SparkContext的初始化(六)_創建和啟動DAGScheduler

Spark源碼剖析——SparkContext的初始化(六)_創建和啟動DAGScheduler

can fail ntp cut set oop 不同 包括 roc

6.創建和啟動DAGScheduler

DAGScheduler主要用於在任務正式交給TaskSchedulerImpl提交之前做一些準備工作,包括:創建Job,將DAG中的RDD劃分到不同的Stage,提交Stage,等等。創建DAGScheduler的代碼如下:

技術分享圖片

DAGScheduler的數據結構主要維護jobId和stageId的關系、Stage、ActiveJob、以及緩存的RDD的partitions的位置信息,見代碼:

技術分享圖片

DAGSchedulerEventProcessLoop能處理的消息類型,比如JobSubmitted、MapStageSubmitted、StageCancelled、JobCancelled、JobGroupCancelled、AllJobsCancelled、ExecutorAdded、ExecutorLost、BeginEvent、GettingResultEvent、completion、TaskSetFailed、ResubmitFailedStages。DAGSchedulerEventProcessLoop接受這些消息後會有不同的處理動作。DAGSchedulerEventProcessLoop的代碼實現如下:

技術分享圖片

Spark源碼剖析——SparkContext的初始化(六)_創建和啟動DAGScheduler