Hadoop 中JobClient 裏 submitJob(JobConf) 和 runJob(JobConf) 的區別

Hadoop提交 Job到JobTracker的時候,需要通過JobClient.runJob(JobConf) 或者 JobClient.submitJob(JobConf) 這兩個靜態方法來提交。但是這兩個方法,前者和後者是有區別的。查看API中的文檔解釋:

1)runJob

runJob

public static RunningJob runJob(JobConf job)
                         throws IOException
Utility that submits a job, then polls for progress until the job is complete.

Parameters:
job - the job configuration.
Throws:
IOException

2)submitJob

submitJob

public RunningJob submitJob(JobConf job)
                     throws FileNotFoundException,
                            InvalidJobConfException,
                            IOException
Submit a job to the MR system. This returns a handle to the RunningJob which can be used to track the running-job.

Parameters:
job - the job configuration.
Returns:
a handle to the RunningJob which can be used to track the running-job.
Throws:
FileNotFoundException
InvalidJobConfException
IOException


       可以看出,runJob是同步的,提交任務後要等待處理直到完成以後,纔會返回RunningJob的handle;而submitJob是異步的,會返回一個處理中的RuningJob的handle,然後等有資源的時候,纔會真正的去執行提交的任務。

      




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章