Java Code Examples for org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext#getAMContainerResourceRequest()

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext#getAMContainerResourceRequest() . 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: RMAppManager.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private ResourceRequest validateAndCreateResourceRequest(
    ApplicationSubmissionContext submissionContext, boolean isRecovery)
    throws InvalidResourceRequestException {
  // Validation of the ApplicationSubmissionContext needs to be completed
  // here. Only those fields that are dependent on RM's configuration are
  // checked here as they have to be validated whether they are part of new
  // submission or just being recovered.

  // Check whether AM resource requirements are within required limits
  if (!submissionContext.getUnmanagedAM()) {
    ResourceRequest amReq = submissionContext.getAMContainerResourceRequest();
    if (amReq == null) {
      amReq = BuilderUtils
          .newResourceRequest(RMAppAttemptImpl.AM_CONTAINER_PRIORITY,
              ResourceRequest.ANY, submissionContext.getResource(), 1);
    }

    // set label expression for AM container
    if (null == amReq.getNodeLabelExpression()) {
      amReq.setNodeLabelExpression(submissionContext
          .getNodeLabelExpression());
    }

    try {
      SchedulerUtils.normalizeAndValidateRequest(amReq,
          scheduler.getMaximumResourceCapability(),
          submissionContext.getQueue(), scheduler, isRecovery, rmContext);
    } catch (InvalidResourceRequestException e) {
      LOG.warn("RM app submission failed in validating AM resource request"
          + " for application " + submissionContext.getApplicationId(), e);
      throw e;
    }

    SchedulerUtils.normalizeRequest(amReq, scheduler.getResourceCalculator(),
        scheduler.getClusterResource(),
        scheduler.getMinimumResourceCapability(),
        scheduler.getMaximumResourceCapability(),
        scheduler.getMinimumResourceCapability());
    return amReq;
  }
  
  return null;
}
 
Example 2
Source File: RMAppManager.java    From big-c with Apache License 2.0 4 votes vote down vote up
private ResourceRequest validateAndCreateResourceRequest(
    ApplicationSubmissionContext submissionContext, boolean isRecovery)
    throws InvalidResourceRequestException {
  // Validation of the ApplicationSubmissionContext needs to be completed
  // here. Only those fields that are dependent on RM's configuration are
  // checked here as they have to be validated whether they are part of new
  // submission or just being recovered.

  // Check whether AM resource requirements are within required limits
  if (!submissionContext.getUnmanagedAM()) {
    ResourceRequest amReq = submissionContext.getAMContainerResourceRequest();
    if (amReq == null) {
      amReq = BuilderUtils
          .newResourceRequest(RMAppAttemptImpl.AM_CONTAINER_PRIORITY,
              ResourceRequest.ANY, submissionContext.getResource(), 1);
    }

    // set label expression for AM container
    if (null == amReq.getNodeLabelExpression()) {
      amReq.setNodeLabelExpression(submissionContext
          .getNodeLabelExpression());
    }

    try {
      SchedulerUtils.normalizeAndValidateRequest(amReq,
          scheduler.getMaximumResourceCapability(),
          submissionContext.getQueue(), scheduler, isRecovery, rmContext);
    } catch (InvalidResourceRequestException e) {
      LOG.warn("RM app submission failed in validating AM resource request"
          + " for application " + submissionContext.getApplicationId(), e);
      throw e;
    }

    SchedulerUtils.normalizeRequest(amReq, scheduler.getResourceCalculator(),
        scheduler.getClusterResource(),
        scheduler.getMinimumResourceCapability(),
        scheduler.getMaximumResourceCapability(),
        scheduler.getMinimumResourceCapability());
    return amReq;
  }
  
  return null;
}