Capacity Scheduler--APP_ATTEMPT_ADDED事件的处理(详见8)

Capacity Scheduler(基于hadoop 2.7.6)

在这里插入图片描述
Capacity Scheduler 主要功能:
1.应用程序初始化
       应用程序提交到ResourceManager后,ResouceManager会向Capacity Scheduler发送一个SchedulerEventType.APP_ADDED事件,Capacity Scheduler收到该事件后,将为应用程序创建一个SchedulerApplication(主要包括queue,user,FiCaSchedulerApp成员)对象跟踪和维护该应用程序的运行时信息,同时将应用程序提交到对应的叶子队列,叶子队列会对应用程序进行一系列合法性检查.

2.资源调度
       当ResourceManager收到来自NodeManager发送的心跳信息后,将向Capacity Scheduler发送一个SchedulerEventType.NODE_UPDATE事件,Capacity Scheduler收到该事件后,会依次进行一下操作:
       (1)处理心跳信息

       (2)资源分配


APP_ATTEMPT_ADDED事件主要处理逻辑:
     1.创建FiCaSchedulerApp类型的application,通过队列资源上限和用户资源上限检查后,记录到队列的activeApplications等待资源调度分配(即收到数据节点的NODE_UPDATE事件时进行资源调度分配).
     2.触发RMAppAttemptEventType.ATTEMPT_ADDED事件,该事件由ScheduleTransition转换器处理.

下面贴贴SchedulerEventType.APP_ATTEMPT_ADDED的处理代码清单:

@Override
  public void CapacityScheduler.handle(SchedulerEvent event) {
   
  ...省略...
 /**
     * 	1.利用user的pendingApplications和activateApplications两个域计数用户启动的应用程序数量
     * 	2.利用队列的pengdingApplications和activateApplications两个域,切换计算是否符合资源上限:
     * 		符合则加入队列的activateApplications列表等待资源调度分配
     */
    case APP_ATTEMPT_ADDED:
    {
   
      AppAttemptAddedSchedulerEvent appAttemptAddedEvent =
          (AppAttemptAddedSchedulerEvent) event;
      addApplicationAttempt(appAttemptAddedEvent.getApplicationAttemptId(),
        appAttemptAddedEvent.getTransferStateFromPreviousAttempt(),
        appAttemptAddedEvent.getIsAttemptRecovering());
    }
    break;
...省略...
    }
private synchronized void addApplicationAttempt(
      ApplicationAttemptId applicationAttemptId,
      boolean transferStateFromPreviousAttempt,
      boolean isAttemptRecovering) {
   
	  /**
	   * 	在处理SchedulerEventType.APP_ADDED事件时,已经实例化了SchedulerApplication对象
	   * 	FiCaSchedulerApp类我的理解: 它是在Application Attempt在Scheduler端的实现
	   */
    SchedulerApplication<FiCaSchedulerApp> application =
        applications.get(applicationAttemptId.getApplicationId());
    if (application == null) {
   
      LOG.warn("Application " + applicationAttemptId.getApplicationId() +
          " cannot be found in scheduler.");
      return;
    }
    CSQueue queue = (CSQueue) application.getQueue();

    /**
     * 	创建FiCaSchedulerApp用于记录AppAttempt运行信息
     * 		FiCaSchedulerApp继承自SchedulerApplicationAttempt
     * 		主要主体分配逻辑相关的主要成员是
     * 			1.appSchedulingInfo:AppSchedulingInfo
     * 			2.attemptId:ApplicationAttemptId
     * 			3.liveContainers:Map<ContainerId, RMContainer>
     * 		appSchedulingInfo里有一个Map<Priority, Map<String, ResourceRequest>>类型的需求列表,后面进行资源分配时根据其具体值进行判断是否可以分配.
     */
    FiCaSchedulerApp attempt =
        new FiCaSchedulerApp(applicationAttemptId, application.getUser
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值