分享

Yarn源码问题

tomson8975 发表于 2015-5-9 01:47:20 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 1 13694
AMRMClientImpl#addContainerRequest里面的[mw_shl_code=applescript,true]  // check that specific and non-specific requests cannot be mixed within a
    // priority
    checkLocalityRelaxationConflict(req.getPriority(), ANY_LIST,
        req.getRelaxLocality());
    // check that specific rack cannot be mixed with specific node within a
    // priority. If node and its rack are both specified then they must be
    // in the same request.
    // For explicitly requested racks, we set locality relaxation to true
    checkLocalityRelaxationConflict(req.getPriority(), dedupedRacks, true);
    checkLocalityRelaxationConflict(req.getPriority(), inferredRacks,
        req.getRelaxLocality());[/mw_shl_code]
这几行的作用是什么,没看懂

[mw_shl_code=applescript,true]/**
   * ContainerRequests with locality relaxation cannot be made at the same
   * priority as ContainerRequests without locality relaxation.
   */
  private void checkLocalityRelaxationConflict(Priority priority,
      Collection<String> locations, boolean relaxLocality) {
    Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests =
        this.remoteRequestsTable.get(priority);
    if (remoteRequests == null) {
      return;
    }
    // Locality relaxation will be set to relaxLocality for all implicitly
    // requested racks. Make sure that existing rack requests match this.
    for (String location : locations) {
        TreeMap<Resource, ResourceRequestInfo> reqs =
            remoteRequests.get(location);
        if (reqs != null && !reqs.isEmpty()) {
          boolean existingRelaxLocality =
              reqs.values().iterator().next().remoteRequest.getRelaxLocality();
          if (relaxLocality != existingRelaxLocality) {
            throw new InvalidContainerRequestException("Cannot submit a "
                + "ContainerRequest asking for location " + location
                + " with locality relaxation " + relaxLocality + " when it has "
                + "already been requested with locality relaxation " + existingRelaxLocality);
          }
        }
      }
  }[/mw_shl_code]

已有(1)人评论

跳转到指定楼层
arsenduan 发表于 2015-5-9 02:51:36


个人看法仅供参考

总的来说就是对申请资源优先级的一个处理
  checkLocalityRelaxationConflict(req.getPriority(), ANY_LIST,
      req.getRelaxLocality());
优先级的检测,这个跟调度策略有关系

下面是检测机架和机架所属节点的优先权
如果机架和节点都被指定,他们优先级都是一样的。


为了明确机架请求,设置 locality relaxation为true
  checkLocalityRelaxationConflict(req.getPriority(), dedupedRacks, true);

下面则是通过  req.getRelaxLocality()来获取
  checkLocalityRelaxationConflict(req.getPriority(), inferredRacks,
      req.getRelaxLocality());

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条