hadoop 2.6 ApplicationMasterProtocol分析

ApplicationMasterProtocol是ApiplicationMaster和ResourceManager之间的接口,有3 个方法。


/**
 * <p>The protocol between a live instance of <code>ApplicationMaster</code> 
 * and the <code>ResourceManager</code>.</p>
 * 
 * <p>This is used by the <code>ApplicationMaster</code> to register/unregister
 * and to request and obtain resources in the cluster from the
 * <code>ResourceManager</code>.</p>
 */
@Public
@Stable
public interface ApplicationMasterProtocol {

  /**
   * <p>
   * The interface used by a new <code>ApplicationMaster</code> to register with
   * the <code>ResourceManager</code>.
   * </p>
   * 
   * <p>
   * The <code>ApplicationMaster</code> needs to provide details such as RPC
   * Port, HTTP tracking url etc. as specified in
   * {@link RegisterApplicationMasterRequest}.
   * </p>
   * 
   * <p>
   * The <code>ResourceManager</code> responds with critical details such as
   * maximum resource capabilities in the cluster as specified in
   * {@link RegisterApplicationMasterResponse}.
   * </p>
   * 
   * @param request
   *          registration request
   * @return registration respose
   * @throws YarnException
   * @throws IOException
   * @throws InvalidApplicationMasterRequestException
   *           The exception is thrown when an ApplicationMaster tries to
   *           register more then once.
   * @see RegisterApplicationMasterRequest
   * @see RegisterApplicationMasterResponse
   */
  @Public
  @Stable
  @Idempotent
  public RegisterApplicationMasterResponse registerApplicationMaster(
      RegisterApplicationMasterRequest request) 
  throws YarnException, IOException;
  
  /**
   * <p>The interface used by an <code>ApplicationMaster</code> to notify the 
   * <code>ResourceManager</code> about its completion (success or failed).</p>
   * 
   * <p>The <code>ApplicationMaster</code> has to provide details such as 
   * final state, diagnostics (in case of failures) etc. as specified in 
   * {@link FinishApplicationMasterRequest}.</p>
   * 
   * <p>The <code>ResourceManager</code> responds with 
   * {@link FinishApplicationMasterResponse}.</p>
   * 
   * @param request completion request
   * @return completion response
   * @throws YarnException
   * @throws IOException
   * @see FinishApplicationMasterRequest
   * @see FinishApplicationMasterResponse
   */
  @Public
  @Stable
  @AtMostOnce
  public FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request) 
  throws YarnException, IOException;

  /**
   * <p>
   * The main interface between an <code>ApplicationMaster</code> and the
   * <code>ResourceManager</code>.
   * </p>
   * 
   * <p>
   * The <code>ApplicationMaster</code> uses this interface to provide a list of
   * {@link ResourceRequest} and returns unused {@link Container} allocated to
   * it via {@link AllocateRequest}. Optionally, the
   * <code>ApplicationMaster</code> can also <em>blacklist</em> resources which
   * it doesn't want to use.
   * </p>
   * 
   * <p>
   * This also doubles up as a <em>heartbeat</em> to let the
   * <code>ResourceManager</code> know that the <code>ApplicationMaster</code>
   * is alive. Thus, applications should periodically make this call to be kept
   * alive. The frequency depends on
   * {@link YarnConfiguration#RM_AM_EXPIRY_INTERVAL_MS} which defaults to
   * {@link YarnConfiguration#DEFAULT_RM_AM_EXPIRY_INTERVAL_MS}.
   * </p>
   * 
   * <p>
   * The <code>ResourceManager</code> responds with list of allocated
   * {@link Container}, status of completed containers and headroom information
   * for the application.
   * </p>
   * 
   * <p>
   * The <code>ApplicationMaster</code> can use the available headroom
   * (resources) to decide how to utilized allocated resources and make informed
   * decisions about future resource requests.
   * </p>
   * 
   * @param request
   *          allocation request
   * @return allocation response
   * @throws YarnException
   * @throws IOException
   * @throws InvalidApplicationMasterRequestException
   *           This exception is thrown when an ApplicationMaster calls allocate
   *           without registering first.
   * @throws InvalidResourceBlacklistRequestException
   *           This exception is thrown when an application provides an invalid
   *           specification for blacklist of resources.
   * @throws InvalidResourceRequestException
   *           This exception is thrown when a {@link ResourceRequest} is out of
   *           the range of the configured lower and upper limits on the
   *           resources.
   * @see AllocateRequest
   * @see AllocateResponse
   */
  @Public
  @Stable
  @AtMostOnce
  public AllocateResponse allocate(AllocateRequest request) 
  throws YarnException, IOException;
}

其中allocate方法是最重要的方法。

AllocateRequest类,包含response id来跟踪重复的响应。

                              作业进度信息。

                              一个资源请求列表。

                             一个资源释放列表。注解如下:

/**
 * <p>The core request sent by the <code>ApplicationMaster</code> to the 
 * <code>ResourceManager</code> to obtain resources in the cluster.</p> 
 *
 * <p>The request includes:
 *   <ul>
 *     <li>A response id to track duplicate responses.</li>
 *     <li>Progress information.</li>
 *     <li>
 *       A list of {@link ResourceRequest} to inform the 
 *       <code>ResourceManager</code> about the application's 
 *       resource requirements.
 *     </li>
 *     <li>
 *       A list of unused {@link Container} which are being returned. 
 *     </li>
 *   </ul>
 * </p>
 * 
 * @see ApplicationMasterProtocol#allocate(AllocateRequest)
 */


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值