yarn3.2源码分析之ApplicationMaster与NodeManager之间的通信

概述

ApplicationMaster与NodeManager之间通过ContainerManagementProtocol进行通信。

ContainerManagementProtocol

ApplicationMaster与NodeManager之间的通信消息主要包括:

startContainers:

stopContainers:

getContainerStatus:

@Public
@Stable
public interface ContainerManagementProtocol {

  /**
   * <p>
   * The <code>ApplicationMaster</code> provides a list of
   * {@link StartContainerRequest}s to a <code>NodeManager</code> to
   * <em>start</em> {@link Container}s allocated to it using this interface.
   * </p>
   * 
   * <p>
   * The <code>ApplicationMaster</code> has to provide details such as allocated
   * resource capability, security tokens (if enabled), command to be executed
   * to start the container, environment for the process, necessary
   * binaries/jar/shared-objects etc. via the {@link ContainerLaunchContext} in
   * the {@link StartContainerRequest}.
   * </p>
   * 
   * <p>
   * The <code>NodeManager</code> sends a response via
   * {@link StartContainersResponse} which includes a list of
   * {@link Container}s of successfully launched {@link Container}s, a
   * containerId-to-exception map for each failed {@link StartContainerRequest} in
   * which the exception indicates errors from per container and a
   * allServicesMetaData map between the names of auxiliary services and their
   * corresponding meta-data. Note: None-container-specific exceptions will
   * still be thrown by the API method itself.
   * </p>
   * <p>
   * The <code>ApplicationMaster</code> can use
   * {@link #getContainerStatuses(GetContainerStatusesRequest)} to get updated
   * statuses of the to-be-launched or launched containers.
   * </p>
   * 
   * @param request
   *          request to start a list of containers
   * @return response including conatinerIds of all successfully launched
   *         containers, a containerId-to-exception map for failed requests and
   *         a allServicesMetaData map.
   * @throws YarnException
   * @throws IOException
   */
  @Public
  @Stable
  StartContainersResponse startContainers(StartContainersRequest request)
      throws YarnException, IOException;

  /**
   * <p>
   * The <code>ApplicationMaster</code> requests a <code>NodeManager</code> to
   * <em>stop</em> a list of {@link Container}s allocated to it using this
   * interface.
   * </p>
   * 
   * <p>
   * The <code>ApplicationMaster</code> sends a {@link StopContainersRequest}
   * which includes the {@link ContainerId}s of the containers to be stopped.
   * </p>
   * 
   * <p>
   * The <code>NodeManager</code> sends a response via
   * {@link StopContainersResponse} which includes a list of {@link ContainerId}
   * s of successfully stopped containers, a containerId-to-exception map for
   * each failed request in which the exception indicates errors from per
   * container. Note: None-container-specific exceptions will still be thrown by
   * the API method itself. <code>ApplicationMaster</code> can use
   * {@link #getContainerStatuses(GetContainerStatusesRequest)} to get updated
   * statuses of the containers.
   * </p>
   * 
   * @param request
   *          request to stop a list of containers
   * @return response which includes a list of containerIds of successfully
   *         stopped containers, a containerId-to-exception map for failed
   *         requests.
   * @throws YarnException
   * @throws IOException
   */
  @Public
  @Stable
  StopContainersResponse stopContainers(StopContainersRequest request)
      throws YarnException, IOException;

  /**
   * <p>
   * The API used by the <code>ApplicationMaster</code> to request for current
   * statuses of <code>Container</code>s from the <code>NodeManager</code>.
   * </p>
   * 
   * <p>
   * The <code>ApplicationMaster</code> sends a
   * {@link GetContainerStatusesRequest} which includes the {@link ContainerId}s
   * of all containers whose statuses are needed.
   * </p>
   * 
   * <p>
   * The <code>NodeManager</code> responds with
   * {@link GetContainerStatusesResponse} which includes a list of
   * {@link ContainerStatus} of the successfully queried containers and a
   * containerId-to-exception map for each failed request in which the exception
   * indicates errors from per container. Note: None-container-specific
   * exceptions will still be thrown by the API method itself.
   * </p>
   * 
   * @param request
   *          request to get <code>ContainerStatus</code>es of containers with
   *          the specified <code>ContainerId</code>s
   * @return response containing the list of <code>ContainerStatus</code> of the
   *         successfully queried containers and a containerId-to-exception map
   *         for failed requests.
   * 
   * @throws YarnException
   * @throws IOException
   */
  @Public
  @Stable
  GetContainerStatusesResponse getContainerStatuses(
      GetContainerStatusesRequest request) throws YarnException,
      IOException;

  /**
   * <p>
   * The API used by the <code>ApplicationMaster</code> to request for
   * resource increase of running containers on the <code>NodeManager</code>.
   * </p>
   *
   * @param request
   *         request to increase resource of a list of containers
   * @return response which includes a list of containerIds of containers
   *         whose resource has been successfully increased and a
   *         containerId-to-exception map for failed requests.
   *
   * @throws YarnException
   * @throws IOException
   */
  @Public
  @Unstable
  @Deprecated
  IncreaseContainersResourceResponse increaseContainersResource(
      IncreaseContainersResourceRequest request) throws YarnException,
      IOException;

  /**
   * <p>
   * The API used by the <code>ApplicationMaster</code> to request for
   * resource update of running containers on the <code>NodeManager</code>.
   * </p>
   *
   * @param request
   *         request to update resource of a list of containers
   * @return response which includes a list of containerIds of containers
   *         whose resource has been successfully updated and a
   *         containerId-to-exception map for failed requests.
   *
   * @throws YarnException Exception specific to YARN
   * @throws IOException IOException thrown from NodeManager
   */
  @Public
  @Unstable
  ContainerUpdateResponse updateContainer(ContainerUpdateRequest request)
      throws YarnException, IOException;

  SignalContainerResponse signalToContainer(SignalContainerRequest request)
      throws YarnException, IOException;

  /**
   * Localize resources required by the container.
   * Currently, this API only works for running containers.
   *
   * @param request Specify the resources to be localized.
   * @return Response that the localize request is accepted.
   * @throws YarnException Exception specific to YARN
   * @throws IOException IOException thrown from the RPC layer.
   */
  @Public
  @Unstable
  ResourceLocalizationResponse localize(ResourceLocalizationRequest request)
    throws YarnException, IOException;

  /**
   * ReInitialize the Container with a new Launch Context.
   * @param request Specify the new ContainerLaunchContext.
   * @return Response that the ReInitialize request is accepted.
   * @throws YarnException Exception specific to YARN.
   * @throws IOException IOException thrown from the RPC layer.
   */
  @Public
  @Unstable
  ReInitializeContainerResponse reInitializeContainer(
      ReInitializeContainerRequest request) throws YarnException, IOException;

  /**
   * Restart the container.
   * @param containerId Container Id.
   * @return Response that the restart request is accepted.
   * @throws YarnException Exception specific to YARN.
   * @throws IOException IOException thrown from the RPC layer.
   */
  @Public
  @Unstable
  RestartContainerResponse restartContainer(ContainerId containerId)
      throws YarnException, IOException;


}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值