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

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext#getApplicationName() . 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: RMHATestBase.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected void submitApplication(
    ApplicationSubmissionContext submissionContext, long submitTime,
    String user) throws YarnException {
  //Do nothing, just add the application to RMContext
  RMAppImpl application =
      new RMAppImpl(submissionContext.getApplicationId(), this.rmContext,
          this.conf, submissionContext.getApplicationName(), user,
          submissionContext.getQueue(), submissionContext,
          this.rmContext.getScheduler(),
          this.rmContext.getApplicationMasterService(),
          submitTime, submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(), null);
  this.rmContext.getRMApps().put(submissionContext.getApplicationId(),
      application);
  //Do not send RMAppEventType.START event
  //so the state of Application will not reach to NEW_SAVING state.
}
 
Example 2
Source File: RMHATestBase.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected void submitApplication(
    ApplicationSubmissionContext submissionContext, long submitTime,
    String user) throws YarnException {
  //Do nothing, just add the application to RMContext
  RMAppImpl application =
      new RMAppImpl(submissionContext.getApplicationId(), this.rmContext,
          this.conf, submissionContext.getApplicationName(), user,
          submissionContext.getQueue(), submissionContext,
          this.rmContext.getScheduler(),
          this.rmContext.getApplicationMasterService(),
          submitTime, submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(), null);
  this.rmContext.getRMApps().put(submissionContext.getApplicationId(),
      application);
  //Do not send RMAppEventType.START event
  //so the state of Application will not reach to NEW_SAVING state.
}
 
Example 3
Source File: RMAppManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private RMAppImpl createAndPopulateNewRMApp(
    ApplicationSubmissionContext submissionContext, long submitTime,
    String user, boolean isRecovery) throws YarnException {
  ApplicationId applicationId = submissionContext.getApplicationId();
  ResourceRequest amReq =
      validateAndCreateResourceRequest(submissionContext, isRecovery);

  // Create RMApp
  RMAppImpl application =
      new RMAppImpl(applicationId, rmContext, this.conf,
          submissionContext.getApplicationName(), user,
          submissionContext.getQueue(),
          submissionContext, this.scheduler, this.masterService,
          submitTime, submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(), amReq);

  // Concurrent app submissions with same applicationId will fail here
  // Concurrent app submissions with different applicationIds will not
  // influence each other
  if (rmContext.getRMApps().putIfAbsent(applicationId, application) !=
      null) {
    String message = "Application with id " + applicationId
        + " is already present! Cannot add a duplicate!";
    LOG.warn(message);
    throw new YarnException(message);
  }
  // Inform the ACLs Manager
  this.applicationACLsManager.addApplication(applicationId,
      submissionContext.getAMContainerSpec().getApplicationACLs());
  String appViewACLs = submissionContext.getAMContainerSpec()
      .getApplicationACLs().get(ApplicationAccessType.VIEW_APP);
  rmContext.getSystemMetricsPublisher().appACLsUpdated(
      application, appViewACLs, System.currentTimeMillis());
  return application;
}
 
Example 4
Source File: TestRMAppTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void testRecoverApplication(ApplicationStateData appState,
    RMState rmState)
    throws Exception {
  ApplicationSubmissionContext submissionContext =
      appState.getApplicationSubmissionContext();
  RMAppImpl application =
      new RMAppImpl(
          appState.getApplicationSubmissionContext().getApplicationId(),
          rmContext, conf,
          submissionContext.getApplicationName(), null,
          submissionContext.getQueue(), submissionContext, null, null,
          appState.getSubmitTime(), submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(),
          BuilderUtils.newResourceRequest(
              RMAppAttemptImpl.AM_CONTAINER_PRIORITY, ResourceRequest.ANY,
              submissionContext.getResource(), 1));
  Assert.assertEquals(RMAppState.NEW, application.getState());

  RMAppEvent recoverEvent =
      new RMAppRecoverEvent(application.getApplicationId(), rmState);
  // Trigger RECOVER event.
  application.handle(recoverEvent);
  // Application final status looked from recoveredFinalStatus
  Assert.assertTrue("Application is not in recoveredFinalStatus.",
      RMAppImpl.isAppInFinalState(application));

  rmDispatcher.await();
  RMAppState finalState = appState.getState();
  Assert.assertEquals("Application is not in finalState.", finalState,
      application.getState());
}
 
Example 5
Source File: RMAppManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
private RMAppImpl createAndPopulateNewRMApp(
    ApplicationSubmissionContext submissionContext, long submitTime,
    String user, boolean isRecovery) throws YarnException {
  ApplicationId applicationId = submissionContext.getApplicationId();
  ResourceRequest amReq =
      validateAndCreateResourceRequest(submissionContext, isRecovery);

  // Create RMApp
  RMAppImpl application =
      new RMAppImpl(applicationId, rmContext, this.conf,
          submissionContext.getApplicationName(), user,
          submissionContext.getQueue(),
          submissionContext, this.scheduler, this.masterService,
          submitTime, submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(), amReq);

  // Concurrent app submissions with same applicationId will fail here
  // Concurrent app submissions with different applicationIds will not
  // influence each other
  if (rmContext.getRMApps().putIfAbsent(applicationId, application) !=
      null) {
    String message = "Application with id " + applicationId
        + " is already present! Cannot add a duplicate!";
    LOG.warn(message);
    throw new YarnException(message);
  }
  // Inform the ACLs Manager
  this.applicationACLsManager.addApplication(applicationId,
      submissionContext.getAMContainerSpec().getApplicationACLs());
  String appViewACLs = submissionContext.getAMContainerSpec()
      .getApplicationACLs().get(ApplicationAccessType.VIEW_APP);
  rmContext.getSystemMetricsPublisher().appACLsUpdated(
      application, appViewACLs, System.currentTimeMillis());
  return application;
}
 
Example 6
Source File: TestRMAppTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void testRecoverApplication(ApplicationStateData appState,
    RMState rmState)
    throws Exception {
  ApplicationSubmissionContext submissionContext =
      appState.getApplicationSubmissionContext();
  RMAppImpl application =
      new RMAppImpl(
          appState.getApplicationSubmissionContext().getApplicationId(),
          rmContext, conf,
          submissionContext.getApplicationName(), null,
          submissionContext.getQueue(), submissionContext, null, null,
          appState.getSubmitTime(), submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(),
          BuilderUtils.newResourceRequest(
              RMAppAttemptImpl.AM_CONTAINER_PRIORITY, ResourceRequest.ANY,
              submissionContext.getResource(), 1));
  Assert.assertEquals(RMAppState.NEW, application.getState());

  RMAppEvent recoverEvent =
      new RMAppRecoverEvent(application.getApplicationId(), rmState);
  // Trigger RECOVER event.
  application.handle(recoverEvent);
  // Application final status looked from recoveredFinalStatus
  Assert.assertTrue("Application is not in recoveredFinalStatus.",
      RMAppImpl.isAppInFinalState(application));

  rmDispatcher.await();
  RMAppState finalState = appState.getState();
  Assert.assertEquals("Application is not in finalState.", finalState,
      application.getState());
}
 
Example 7
Source File: ClientRMService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public SubmitApplicationResponse submitApplication(
    SubmitApplicationRequest request) throws YarnException {
  ApplicationSubmissionContext submissionContext = request
      .getApplicationSubmissionContext();
  ApplicationId applicationId = submissionContext.getApplicationId();

  // ApplicationSubmissionContext needs to be validated for safety - only
  // those fields that are independent of the RM's configuration will be
  // checked here, those that are dependent on RM configuration are validated
  // in RMAppManager.

  String user = null;
  try {
    // Safety
    user = UserGroupInformation.getCurrentUser().getShortUserName();
  } catch (IOException ie) {
    LOG.warn("Unable to get the current user.", ie);
    RMAuditLogger.logFailure(user, AuditConstants.SUBMIT_APP_REQUEST,
        ie.getMessage(), "ClientRMService",
        "Exception in submitting application", applicationId);
    throw RPCUtil.getRemoteException(ie);
  }

  // Check whether app has already been put into rmContext,
  // If it is, simply return the response
  if (rmContext.getRMApps().get(applicationId) != null) {
    LOG.info("This is an earlier submitted application: " + applicationId);
    return SubmitApplicationResponse.newInstance();
  }

  if (submissionContext.getQueue() == null) {
    submissionContext.setQueue(YarnConfiguration.DEFAULT_QUEUE_NAME);
  }
  if (submissionContext.getApplicationName() == null) {
    submissionContext.setApplicationName(
        YarnConfiguration.DEFAULT_APPLICATION_NAME);
  }
  if (submissionContext.getApplicationType() == null) {
    submissionContext
      .setApplicationType(YarnConfiguration.DEFAULT_APPLICATION_TYPE);
  } else {
    if (submissionContext.getApplicationType().length() > YarnConfiguration.APPLICATION_TYPE_LENGTH) {
      submissionContext.setApplicationType(submissionContext
        .getApplicationType().substring(0,
          YarnConfiguration.APPLICATION_TYPE_LENGTH));
    }
  }

  try {
    // call RMAppManager to submit application directly
    rmAppManager.submitApplication(submissionContext,
        System.currentTimeMillis(), user);

    LOG.info("Application with id " + applicationId.getId() + 
        " submitted by user " + user);
    RMAuditLogger.logSuccess(user, AuditConstants.SUBMIT_APP_REQUEST,
        "ClientRMService", applicationId);
  } catch (YarnException e) {
    LOG.info("Exception in submitting application with id " +
        applicationId.getId(), e);
    RMAuditLogger.logFailure(user, AuditConstants.SUBMIT_APP_REQUEST,
        e.getMessage(), "ClientRMService",
        "Exception in submitting application", applicationId);
    throw e;
  }

  SubmitApplicationResponse response = recordFactory
      .newRecordInstance(SubmitApplicationResponse.class);
  return response;
}
 
Example 8
Source File: ClientRMService.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public SubmitApplicationResponse submitApplication(
    SubmitApplicationRequest request) throws YarnException {
  ApplicationSubmissionContext submissionContext = request
      .getApplicationSubmissionContext();
  ApplicationId applicationId = submissionContext.getApplicationId();

  // ApplicationSubmissionContext needs to be validated for safety - only
  // those fields that are independent of the RM's configuration will be
  // checked here, those that are dependent on RM configuration are validated
  // in RMAppManager.

  String user = null;
  try {
    // Safety
    user = UserGroupInformation.getCurrentUser().getShortUserName();
  } catch (IOException ie) {
    LOG.warn("Unable to get the current user.", ie);
    RMAuditLogger.logFailure(user, AuditConstants.SUBMIT_APP_REQUEST,
        ie.getMessage(), "ClientRMService",
        "Exception in submitting application", applicationId);
    throw RPCUtil.getRemoteException(ie);
  }

  // Check whether app has already been put into rmContext,
  // If it is, simply return the response
  if (rmContext.getRMApps().get(applicationId) != null) {
    LOG.info("This is an earlier submitted application: " + applicationId);
    return SubmitApplicationResponse.newInstance();
  }

  if (submissionContext.getQueue() == null) {
    submissionContext.setQueue(YarnConfiguration.DEFAULT_QUEUE_NAME);
  }
  if (submissionContext.getApplicationName() == null) {
    submissionContext.setApplicationName(
        YarnConfiguration.DEFAULT_APPLICATION_NAME);
  }
  if (submissionContext.getApplicationType() == null) {
    submissionContext
      .setApplicationType(YarnConfiguration.DEFAULT_APPLICATION_TYPE);
  } else {
    if (submissionContext.getApplicationType().length() > YarnConfiguration.APPLICATION_TYPE_LENGTH) {
      submissionContext.setApplicationType(submissionContext
        .getApplicationType().substring(0,
          YarnConfiguration.APPLICATION_TYPE_LENGTH));
    }
  }

  try {
    // call RMAppManager to submit application directly
    rmAppManager.submitApplication(submissionContext,
        System.currentTimeMillis(), user);

    LOG.info("Application with id " + applicationId.getId() + 
        " submitted by user " + user);
    RMAuditLogger.logSuccess(user, AuditConstants.SUBMIT_APP_REQUEST,
        "ClientRMService", applicationId);
  } catch (YarnException e) {
    LOG.info("Exception in submitting application with id " +
        applicationId.getId(), e);
    RMAuditLogger.logFailure(user, AuditConstants.SUBMIT_APP_REQUEST,
        e.getMessage(), "ClientRMService",
        "Exception in submitting application", applicationId);
    throw e;
  }

  SubmitApplicationResponse response = recordFactory
      .newRecordInstance(SubmitApplicationResponse.class);
  return response;
}