Source-level analysis of MapReduce job initialization in Jobtracker

Source: Internet
Author: User
Tags thread

MapReduce Job submission process source level analysis (c) has already explained that the user finally calls the Jobtracker.submitjob method to submit the job to Jobtracker. The core submission method for this method is the Jobtracker.addjob (Jobid Jobid, Jobinprogress Job) method, which submits the job to the scheduler (AddJob by default) Listener Jobqueuejobinprogresslistener and Eagertaskinitializationlistener (this article only discusses the default scheduler), use the method jobadded (jobinprogress job), The Jobqueuejobinprogresslistener task is to monitor the changes in the lifecycle of each jobinprocess, and Eagertaskinitializationlistener to initialize the new job after it is discovered.

First, jobqueuejobinprogresslistener.jobadded (jobinprogress Job) method. For a code jobqueue.put (new Jobschedulinginfo (Job.getstatus ()), job, build a Jobschedulinginfo object first, Then it corresponds to the jobinprogress and puts it into the jobqueue. The Jobschedulinginfo class maintains some of the information that this job must have, such as priority (the default is normal), Jobid, and start-time starttime.

Second, eagertaskinitializationlistener.jobadded (jobinprogress Job) method.

/**
   * We Add the JIP to the Jobinitqueue, which are processed 
   * asynchronously to handle split-computation and Buil D up
   * the right tasktracker/block mapping.
   */
  @Override public
  void jobadded (jobinprogress job) {
    synchronized (jobinitqueue) {
      Jobinitqueue.add (Job); Add into list<jobinprogress> jobinitqueue
      resortinitqueue ();
      Jobinitqueue.notifyall (); Wake blocked Process
    }
    
  }

The Resortinitqueue () method in the above method is primarily to sort the jobinprocess in Jobinitqueue, first by priority, and then by the start time. Eagertaskinitializationlistener.start () is invoked when the scheduler Initializes Jobqueuetaskscheduler.start (), so it is called before the jobadded method. The Eagertaskinitializationlistener.start () code is as follows:

1 public void Start () throws IOException {
2 This.jobinitmanagerthread = new Thread (Jobinitmanager, "Jobinitmanager");
3 Jobinitmanagerthread.setdaemon (TRUE);
4 This.jobInitManagerThread.start ();
5}

The

Start () method starts a thread: Jobinitmanager.

Used to init new jobs that have just been created
       
    Class Jobinitmanager implements Runnable {
      public void Run () {jobinprogress job = null;
              while (true) {The try {synchronized (jobinitqueue) {while (Jobinitqueue.isempty ()) {
            Jobinitqueue.wait ();
          Job = jobinitqueue.remove (0);
        } threadpool.execute (New Initjob (Job));
          catch (Interruptedexception t) {log.info ("Jobinitmanagerthread interrupted.");
        Break
      } log.info ("Shutting down thread pool");
    Threadpool.shutdownnow ();
        
    } class Initjob implements Runnable {private jobinprogress job;
    Public initjob (jobinprogress job) {this.job = job; public void Run () {Ttm.iniTjob (Job)///corresponding Jobtracker corresponding method}} 

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.