MapReduce源码分析之JobSubmitter(一)

本文深入剖析MapReduce中的JobSubmitter,它是作业提交的核心组件。主要讨论submitJobInternal()方法,包括校验输出路径、配置信息、分布式缓存、作业ID生成、队列权限控制等关键步骤,详细解释了MapReduce作业提交的流程。
摘要由CSDN通过智能技术生成

        JobSubmitter,顾名思义,它是MapReduce中作业提交者,而实际上JobSubmitter除了构造方法外,对外提供的唯一一个非private成员变量或方法就是submitJobInternal()方法,它是提交Job的内部方法,实现了提交Job的所有业务逻辑。本文,我们将深入研究MapReduce中用于提交Job的组件JobSubmitter。

        首先,我们先看下JobSubmitter的类成员变量,如下:

  // 文件系统FileSystem实例
  private FileSystem jtFs;
  // 客户端通信协议ClientProtocol实例
  private ClientProtocol submitClient;
  // 提交作业的主机名
  private String submitHostName;
  // 提交作业的主机地址
  private String submitHostAddress;
        它一共有四个类成员变量,分别为:

        1、文件系统FileSystem实例jtFs:用于操作作业运行需要的各种文件等;

        2、客户端通信协议ClientProtocol实例submitClient:用于与集群交互,完成作业提交、作业状态查询等;

        3、提交作业的主机名submitHostName;

        4、提交作业的主机地址submitHostAddress。

        其中,客户端通信协议ClientProtocol实例submitClient是通过Cluster的客户端通信协议ClientProtocol实例client来赋值的,我们在《MapReduce源码分析之新API作业提交(二):连接集群》一文中曾经提到过,它根据MapReduce中参数mapreduce.framework.name的配置为yarn或local,有Yarn模式的YARNRunner和Local模式的LocalJobRunner两种情况。
        接下来,我们再看下JobSubmitter的构造函数,如下:

  JobSubmitter(FileSystem submitFs, ClientProtocol submitClient) 
  throws IOException {
	  
	// 根据入参赋值成员变量submitClient、jtFs
    this.submitClient = submitClient;
    this.jtFs = submitFs;
  }
        很简单,根据入参赋值成员变量submitClient、jtFs而已。

        关键的来了,我们看下JobSubmitter唯一的对外核心功能方法submitJobInternal(),它被用于提交作业至集群,代码如下:

  /**
   * Internal method for submitting jobs to the system.
   * 
   * <p>The job submission process involves:
   * <ol>
   *   <li>
   *   Checking the input and output specifications of the job.
   *   </li>
   *   <li>
   *   Computing the {@link InputSplit}s for the job.
   *   </li>
   *   <li>
   *   Setup the requisite accounting information for the 
   *   {@link DistributedCache} of the job, if necessary.
   *   </li>
   *   <li>
   *   Copying the job's jar and configuration to the map-reduce system
   *   directory on the distributed file-system. 
   *   </li>
   *   <li>
   *   Submitting the job to the <code>JobTracker</code> and optionally
   *   monitoring it's status.
   *   </li>
   * </ol></p>
   * @param job the configuration to submit
   * @param cluster the handle to the Cluster
   * @throws ClassNotFoundException
   * @throws InterruptedException
   * @throws IOException
   */
  JobStatus submitJobInternal(Job job, Cluster cluster) 
  throws ClassNotFoundException, InterruptedException, IOException {

    //validate the jobs output spe
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值