Java Code Examples for org.apache.hadoop.yarn.api.records.Container#getPriority()

The following examples show how to use org.apache.hadoop.yarn.api.records.Container#getPriority() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RMContainerAllocator.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private ContainerRequest assignWithoutLocality(Container allocated) {
  ContainerRequest assigned = null;
  
  Priority priority = allocated.getPriority();
  if (PRIORITY_FAST_FAIL_MAP.equals(priority)) {
    LOG.info("Assigning container " + allocated + " to fast fail map");
    assigned = assignToFailedMap(allocated);
  } else if (PRIORITY_REDUCE.equals(priority)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Assigning container " + allocated + " to reduce");
    }
    assigned = assignToReduce(allocated);
  }
    
  return assigned;
}
 
Example 2
Source File: RMContainerAllocator.java    From big-c with Apache License 2.0 6 votes vote down vote up
private ContainerRequest assignWithoutLocality(Container allocated) {
  ContainerRequest assigned = null;
  
  Priority priority = allocated.getPriority();
  if (PRIORITY_FAST_FAIL_MAP.equals(priority)) {
    LOG.info("Assigning container " + allocated + " to fast fail map");
    assigned = assignToFailedMap(allocated);
  } else if (PRIORITY_REDUCE.equals(priority)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Assigning container " + allocated + " to reduce");
    }
    assigned = assignToReduce(allocated);
  }
    
  return assigned;
}
 
Example 3
Source File: YarnTaskSchedulerService.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
private CookieContainerRequest getMatchingRequestWithPriority(
    Container container,
    String location) {
  Priority priority = container.getPriority();
  Resource capability = container.getResource();
  List<? extends Collection<CookieContainerRequest>> requestsList =
      amRmClient.getMatchingRequests(priority, location, capability);

  if (!requestsList.isEmpty()) {
    // pick first one
    for (Collection<CookieContainerRequest> requests : requestsList) {
      for (CookieContainerRequest cookieContainerRequest : requests) {
        if (canAssignTaskToContainer(cookieContainerRequest, container)) {
          return cookieContainerRequest;
        }
      }
    }
  }

  return null;
}
 
Example 4
Source File: YarnTaskSchedulerService.java    From tez with Apache License 2.0 6 votes vote down vote up
private CookieContainerRequest getMatchingRequestWithPriority(
    Container container,
    String location) {
  Priority priority = container.getPriority();
  Resource capability = container.getResource();
  List<? extends Collection<CookieContainerRequest>> requestsList =
      amRmClient.getMatchingRequests(priority, location, capability);

  if (!requestsList.isEmpty()) {
    // pick first one
    for (Collection<CookieContainerRequest> requests : requestsList) {
      for (CookieContainerRequest cookieContainerRequest : requests) {
        if (canAssignTaskToContainer(cookieContainerRequest, container)) {
          return cookieContainerRequest;
        }
      }
    }
  }

  return null;
}
 
Example 5
Source File: YarnTaskSchedulerService.java    From incubator-tez with Apache License 2.0 4 votes vote down vote up
private synchronized boolean assignReUsedContainerWithLocation(
  Container container,
  ContainerAssigner assigner,
  Map<CookieContainerRequest, Container> assignedContainers,
  boolean honorLocality) {

  Priority containerPriority = container.getPriority();
  Priority topPendingTaskPriority = amRmClient.getTopPriority();
  if (topPendingTaskPriority == null) {
    // nothing left to assign
    return false;
  }
  
  if (topPendingTaskPriority.compareTo(containerPriority) > 0 && 
      heldContainers.get(container.getId()).isNew()) {
    // if the next task to assign is higher priority than the container then 
    // dont assign this container to that task.
    // if task and container are equal priority - then its first use or reuse
    // within the same priority - safe to use
    // if task is lower priority than container then if we use a container that
    // is no longer needed by higher priority tasks All those higher pri tasks 
    // has been assigned resources - safe to use (first use or reuse)
    // if task is higher priority than container then we may end up using a 
    // container that was assigned by the RM for a lower priority pending task 
    // that will be assigned after this higher priority task is assigned. If we
    // use that task's container now then we may not be able to match this 
    // container to that task later on. However the RM has already assigned us 
    // all containers and is not going to give us new containers. We will get 
    // stuck for resources.
    // the above applies for new containers. If a container has already been 
    // re-used then this is not relevant
    return false;
  }
  
  CookieContainerRequest assigned =
    assigner.assignReUsedContainer(container, honorLocality);
  if (assigned != null) {
    assignedContainers.put(assigned, container);
    return true;
  }
  return false;
}
 
Example 6
Source File: YarnTaskSchedulerService.java    From tez with Apache License 2.0 4 votes vote down vote up
private synchronized boolean assignReUsedContainerWithLocation(
  Container container,
  ContainerAssigner assigner,
  Map<CookieContainerRequest, Container> assignedContainers,
  boolean honorLocality) {

  Priority containerPriority = container.getPriority();
  Priority topPendingTaskPriority = amRmClient.getTopPriority();
  if (topPendingTaskPriority == null) {
    // nothing left to assign
    return false;
  }
  
  if (topPendingTaskPriority.compareTo(containerPriority) > 0 && 
      heldContainers.get(container.getId()).isNew()) {
    // if the next task to assign is higher priority than the container then 
    // dont assign this container to that task.
    // if task and container are equal priority - then its first use or reuse
    // within the same priority - safe to use
    // if task is lower priority than container then if we use a container that
    // is no longer needed by higher priority tasks All those higher pri tasks 
    // has been assigned resources - safe to use (first use or reuse)
    // if task is higher priority than container then we may end up using a 
    // container that was assigned by the RM for a lower priority pending task 
    // that will be assigned after this higher priority task is assigned. If we
    // use that task's container now then we may not be able to match this 
    // container to that task later on. However the RM has already assigned us 
    // all containers and is not going to give us new containers. We will get 
    // stuck for resources.
    // the above applies for new containers. If a container has already been 
    // re-used then this is not relevant
    return false;
  }
  
  CookieContainerRequest assigned =
    assigner.assignReUsedContainer(container, honorLocality);
  if (assigned != null) {
    assignedContainers.put(assigned, container);
    return true;
  }
  return false;
}