设为首页 收藏本站
查看: 587|回复: 0

[经验分享] hadoop job提交完成的整个过程介绍 zz

[复制链接]

尚未签到

发表于 2016-12-12 08:26:45 | 显示全部楼层 |阅读模式
2009-11-17 11:16http://blog.iyunv.com/u3/94300/showart_1902760.html

由于大量的使用interface,reflection,rpc proxy,所以当我们提交job给hadoop的时候,他到底是如何一步步运行的确实不太容易看明白,今天费了将近一天的功夫终于将其大概整理了出俩,为以后继续深入仔细阅读源码打下基础。

start JobTracker and TaskTracker by bin/start-all.sh
JobTracker initialization:
read all host( master and slave )
init QueueManager to manage job queue
start JobQueueTaskScheduler to schedule job
add JobQueueJobInProcessListener to manage submited jobs
add EagerTaskInitialization, so when job was submited, JobinitThread will get first job in job queue and execute job ( throught job.initTask)
start JobTracker Server which is instance of RPC.Server, derived from org.apache.hadoop.mapred.ipc.Server, so client can submit job by creating proxy
start httpServer (third party library) so we can get status of job tracker through http
init JobTrackerInstrumentation so record measure information
start RecoverManager so we can try to recover unfinished history jobs
init CompletedJobStatusStore to persist and retrive job information
start ExpireTrackers thread to remove all expiry TaskTracker, whose heatbeat response out of time
start RetireJobs to remove finished jobs that have been around for too long ( the job status is not runing, prepare ... )
start ExpireLaunchingTasks to check task assignment failure and reassign the task
join JobTracker Server to wait for job submit request

TaskTracker initialization:
start http server to report map/reduce status by http
start TaskTrackerInstrument to record measure info
init JvmManager which can find free JVM to run task
start taskReportServer (ipc.Server) with instance as TaskTracker
create JobTracker proxy so the taskTracker can communicate with JobTracker
start mapEventsFetcher to fetch all map event
start mapLauncher and reduceLauncher ( instance of TaskLauncher) thread to monitor task queue, if new task was inserted, get first and startNewTask.
after TaskTracker initialization, start TaskTracker server which will looply communicate with JobTracker by Hearbbeat test, also get task.
check buildVersion and file system
purge map-event and reset reducer
check if the TaskTracker should be restart
get TaskAction from Heartbert message, if exist, add action to actionQueue



org.apache.hadoop.mapred.JobClient :
public static RunningJob runJob(JobConf job)

public RunningJob submitJob(JobConf job)
copy job jar to DFS
get input split
sort input split
write split info into file system
jobSubmitClient.submitJob, jobSubmitClient is client proxy of org.apache.hadoop.mapred.JobTracker, which record status of all jobs

org.apache.hadoop.mapred.JobTracker :
public JobStatus submitJob(JobID jobName)
create JobInProcess with jobID
copy job jar from DFS to local
add job to JobQueueJobInProgressListener and EagerTaskInitializationListener, EagerTaskInitializationListener will call JobInProcess.initTask to create map and reduce task based on InputSplit, and create other assistant task, such as clean-up task ect.
JobTracker call JobQueueTaskScheduler.assignTask to assign task for each request host
call JobTracker.getSetupAndCleanupTasks() to get all tasks waited for execution, call TaskInProcess.addRunningTask() to set map or reduce task
all got tasks were encapsulated in TaskActions
send TaskActions to TaskTrackers through HeartbeatReponse

TaskTracker get TaskAction from HeartbeatResponse message ( JobTracker call JobQueueTaskScheduler.assignTask to assign task for each request host)
TaskTracker.TaskInProcess.registerTask() was called so TaskAction was transformed to Tasktracker.TaskInProcess (tip)
the newly got tip was insert into task queue ( named tasksToLaunch) of TaskLauncher ( named mapLauncher and reduceLauncher), once new task was inserted:
TaskTracker.startNewTask was called
TaskTracker.localizeJob() was called
add task to job, so MapEventFetcher can get map event (further thinking)
get job jar file and create necessary working directory
unjar job jar file
TaskTracker.launchTaskForJob was called
TaskTracker.TaskInProcess.launchTask was called
TaskTracker.TaskInProces.localizeTask() was called
create local working dir
create symlink for job dir if it doesn't exist
set resolved hostname
set debug parameter if debugCommand exist
Task.createRunner (MapTask or ReduceTask) was called
TaskRunner.start()
build parameter for JVM running, JVM was selected by JvmManager which obey singleInstance model
entry of JVM is org.apache.hadoop.mapred.Child which will call, which will call Task.run()
in MapTask.run() or ReduceTask.run(), our mapper or reducer code waw call through
**************
MapRunnable runner = ReflectionUtils.newInstance(job
.getMapRunnerClass(), job);
**************
finally, we finish our map/reduce work.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-312948-1-1.html 上篇帖子: Hadoop进阶之输入路径如何正则通配? 下篇帖子: Cloudera Impala:基于Hadoop的实时查询开源项目
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表