hadoop源码TaskAttemptID TaskTrackerAction JobTracker,FileOutputCommitter相关

1,TaskAttemptID代表task attempt,一个task attempt就是一个map/reduce task 的一个实例taskid,而每个TaskAttemptID由两部分组成:TaskID+task序列号

eg:

attempt_200707121733_0003_m_000005_0

代表2007年07月12日17点33分启动的第0003号作业(job)的第00005号map任务的第0号task attempt

2,TaskTrackerAction的类型有,LaunchTaskAction(),KillTaskAction(),KillJobAction(),ReinitTrackerAction(),CommitTaskAction();

 /**
   * Ennumeration of various 'actions' that the {@link JobTracker}
   * directs the {@link TaskTracker} to perform periodically.
   *
   */
  public static enum ActionType {
    /** Launch a new task. */
    LAUNCH_TASK,
    
    /** Kill a task. */
    KILL_TASK,
    
    /** Kill any tasks of this job and cleanup. */
    KILL_JOB,
    
    /** Reinitialize the tasktracker. */
    REINIT_TRACKER,

    /** Ask a task to save its output. */
    COMMIT_TASK
  };
 
  /**
   * A factory-method to create objects of given {@link ActionType}.
   * @param actionType the {@link ActionType} of object to create.
   * @return an object of {@link ActionType}.
   */
  public static TaskTrackerAction createAction(ActionType actionType) {
    TaskTrackerAction action = null;
    
    switch (actionType) {
    case LAUNCH_TASK:
      {
        action = new LaunchTaskAction();
      }
      break;
    case KILL_TASK:
      {
        action = new KillTaskAction();
      }
      break;
    case KILL_JOB:
      {
        action = new KillJobAction();
      }
      break;
    case REINIT_TRACKER:
      {
        action = new ReinitTrackerAction();
      }
      break;
    case COMMIT_TASK:
      {
        action = new CommitTaskAction();
      }
      break;
    }

    return action;
  }

3,JobTracker中相关:

           offerService()

                   |--taskScheduler.start();

                   |--recoveryManager.recover();

通过RecoveryManager的recover()方法恢复Job

                   |-- this.expireTrackersThread.start();

检测已经失效的TaskTracker节点。

// Used to expire TaskTrackers that have gone down

                   |-- this.retireJobsThread.start();

清除那些已经完成很长时间仍然存在队列中的job

                   |--expireLaunchingTaskThread.start();

停止那些在超时时间内未报告进度的Tasks。

A thread to timeout tasks that have been assigned to task trackers,
   * but that haven't reported back yet.

                   |--completedJobsStoreThread.start();

                   |--this.interTrackerServer.start();/ start the inter-tracker server once the jt is ready
 

  /**
   * Run forever
   */
  public void offerService() throws InterruptedException, IOException {
    // Prepare for recovery. This is done irrespective of the status of restart
    // flag.
    while (true) {
      try {
        recoveryManager.updateRestartCount();
        break;
      } catch (IOException ioe) {
        LOG.warn("Failed to initialize recovery manager. ", ioe);
        // wait for some time
        Thread.sleep(FS_ACCESS_RETRY_PERIOD);
        LOG.warn("Retrying...");
      }
    }

    taskScheduler.start();
    
    //  Start the recovery after starting the scheduler
    try {
      recoveryManager.recover();
    } catch (Throwable t) {
      LOG.warn("Recovery manager crashed! Ignoring.", t);
    }
    
    this.expireTrackersThread = new Thread(this.expireTrackers,
                                          "expireTrackers");
    this.expireTrackersThread.start();
    this.retireJobsThread = new Thread(this.retireJobs, "retireJobs");
    this.retireJobsThread.start();
    expireLaunchingTaskThread.start();

    if (completedJobStatusStore.isActive()) {
      completedJobsStoreThread = new Thread(completedJobStatusStore,
                                            "completedjobsStore-housekeeper");
      completedJobsStoreThread.start();
    }

    // start the inter-tracker server once the jt is ready
    this.interTrackerServer.start();
    
    synchronized (this) {
      state = State.RUNNING;
    }

4, Job的五种状态

 public static final int RUNNING = 1;
  public static final int SUCCEEDED = 2;
  public static final int FAILED = 3;
  public static final int PREP = 4;

  public static final int KILLED = 5;


5,jobStatus信息:

  this.jobid = jobid;
     this.setupProgress = setupProgress;
     this.mapProgress = mapProgress;
     this.reduceProgress = reduceProgress;
     this.cleanupProgress = cleanupProgress;
     this.runState = runState;

6,FileOutputCommitter相关

setupJob:Hadoop初始化时设置job的输出;

commitJob:当job完成时,清除job的输出,这个方法在反馈回来的job状态为SUCCEEDED时调用;

cleanupJob:job结束后清除job的输出;

 // do the clean up of temporary directory

abortJob:当job的返回状态是FAILEDKILLED时,执行该函数,用于终止作业的输出;

setupTask:设置task的输出;

// FileOutputCommitter's setupTask doesn't do anything. Because the
       // temporary task directory is created on demand when the
       // task is writing.

needsTaskCommit:检测task是否需要提交;

commitTask:将task的输出移到作业的输出目录;

// Move the task outputs to their final place

// Delete the temporary task-specific output directory

abortTask:取消task的输出;



 





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值