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:
-
- the job configuration.job
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
which can be used to track the running-job.RunningJob
-
- Parameters:
-
- the job configuration.job
Returns: - a handle to the
which can be used to track the running-job.RunningJob
Throws: -
FileNotFoundException
-
InvalidJobConfException
-
IOException
-
可以看出,runJob是同步的,提交任务后要等待处理直到完成以后,才会返回RunningJob的handle;而submitJob是异步的,会返回一个处理中的RuningJob的handle,然后等有资源的时候,才会真正的去执行提交的任务。