Java Code Examples for org.apache.hadoop.yarn.server.utils.BuilderUtils#newAMRMToken()

The following examples show how to use org.apache.hadoop.yarn.server.utils.BuilderUtils#newAMRMToken() . 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: RMAppImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationReport createAndGetApplicationReport(String clientUserName,
    boolean allowAccess) {
  this.readLock.lock();

  try {
    ApplicationAttemptId currentApplicationAttemptId = null;
    org.apache.hadoop.yarn.api.records.Token clientToAMToken = null;
    String trackingUrl = UNAVAILABLE;
    String host = UNAVAILABLE;
    String origTrackingUrl = UNAVAILABLE;
    int rpcPort = -1;
    ApplicationResourceUsageReport appUsageReport =
        RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
    FinalApplicationStatus finishState = getFinalApplicationStatus();
    String diags = UNAVAILABLE;
    float progress = 0.0f;
    org.apache.hadoop.yarn.api.records.Token amrmToken = null;
    if (allowAccess) {
      trackingUrl = getDefaultProxyTrackingUrl();
      if (this.currentAttempt != null) {
        currentApplicationAttemptId = this.currentAttempt.getAppAttemptId();
        trackingUrl = this.currentAttempt.getTrackingUrl();
        origTrackingUrl = this.currentAttempt.getOriginalTrackingUrl();
        if (UserGroupInformation.isSecurityEnabled()) {
          // get a token so the client can communicate with the app attempt
          // NOTE: token may be unavailable if the attempt is not running
          Token<ClientToAMTokenIdentifier> attemptClientToAMToken =
              this.currentAttempt.createClientToken(clientUserName);
          if (attemptClientToAMToken != null) {
            clientToAMToken = BuilderUtils.newClientToAMToken(
                attemptClientToAMToken.getIdentifier(),
                attemptClientToAMToken.getKind().toString(),
                attemptClientToAMToken.getPassword(),
                attemptClientToAMToken.getService().toString());
          }
        }
        host = this.currentAttempt.getHost();
        rpcPort = this.currentAttempt.getRpcPort();
        appUsageReport = currentAttempt.getApplicationResourceUsageReport();
        progress = currentAttempt.getProgress();
      }
      diags = this.diagnostics.toString();

      if (currentAttempt != null && 
          currentAttempt.getAppAttemptState() == RMAppAttemptState.LAUNCHED) {
        if (getApplicationSubmissionContext().getUnmanagedAM() &&
            clientUserName != null && getUser().equals(clientUserName)) {
          Token<AMRMTokenIdentifier> token = currentAttempt.getAMRMToken();
          if (token != null) {
            amrmToken = BuilderUtils.newAMRMToken(token.getIdentifier(),
                token.getKind().toString(), token.getPassword(),
                token.getService().toString());
          }
        }
      }

      RMAppMetrics rmAppMetrics = getRMAppMetrics();
      appUsageReport.setMemorySeconds(rmAppMetrics.getMemorySeconds());
      appUsageReport.setVcoreSeconds(rmAppMetrics.getVcoreSeconds());
      appUsageReport.setGcoreSeconds(rmAppMetrics.getGcoreSeconds());
    }

    if (currentApplicationAttemptId == null) {
      currentApplicationAttemptId = 
          BuilderUtils.newApplicationAttemptId(this.applicationId, 
              DUMMY_APPLICATION_ATTEMPT_NUMBER);
    }

    return BuilderUtils.newApplicationReport(this.applicationId,
        currentApplicationAttemptId, this.user, this.queue,
        this.name, host, rpcPort, clientToAMToken,
        createApplicationState(), diags,
        trackingUrl, this.startTime, this.finishTime, finishState,
        appUsageReport, origTrackingUrl, progress, this.applicationType, 
        amrmToken, applicationTags);
  } finally {
    this.readLock.unlock();
  }
}
 
Example 2
Source File: RMAppImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationReport createAndGetApplicationReport(String clientUserName,
    boolean allowAccess) {
  this.readLock.lock();

  try {
    ApplicationAttemptId currentApplicationAttemptId = null;
    org.apache.hadoop.yarn.api.records.Token clientToAMToken = null;
    String trackingUrl = UNAVAILABLE;
    String host = UNAVAILABLE;
    String origTrackingUrl = UNAVAILABLE;
    int rpcPort = -1;
    ApplicationResourceUsageReport appUsageReport =
        RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
    FinalApplicationStatus finishState = getFinalApplicationStatus();
    String diags = UNAVAILABLE;
    float progress = 0.0f;
    org.apache.hadoop.yarn.api.records.Token amrmToken = null;
    if (allowAccess) {
      trackingUrl = getDefaultProxyTrackingUrl();
      if (this.currentAttempt != null) {
        currentApplicationAttemptId = this.currentAttempt.getAppAttemptId();
        trackingUrl = this.currentAttempt.getTrackingUrl();
        origTrackingUrl = this.currentAttempt.getOriginalTrackingUrl();
        if (UserGroupInformation.isSecurityEnabled()) {
          // get a token so the client can communicate with the app attempt
          // NOTE: token may be unavailable if the attempt is not running
          Token<ClientToAMTokenIdentifier> attemptClientToAMToken =
              this.currentAttempt.createClientToken(clientUserName);
          if (attemptClientToAMToken != null) {
            clientToAMToken = BuilderUtils.newClientToAMToken(
                attemptClientToAMToken.getIdentifier(),
                attemptClientToAMToken.getKind().toString(),
                attemptClientToAMToken.getPassword(),
                attemptClientToAMToken.getService().toString());
          }
        }
        host = this.currentAttempt.getHost();
        rpcPort = this.currentAttempt.getRpcPort();
        appUsageReport = currentAttempt.getApplicationResourceUsageReport();
        progress = currentAttempt.getProgress();
      }
      diags = this.diagnostics.toString();

      if (currentAttempt != null && 
          currentAttempt.getAppAttemptState() == RMAppAttemptState.LAUNCHED) {
        if (getApplicationSubmissionContext().getUnmanagedAM() &&
            clientUserName != null && getUser().equals(clientUserName)) {
          Token<AMRMTokenIdentifier> token = currentAttempt.getAMRMToken();
          if (token != null) {
            amrmToken = BuilderUtils.newAMRMToken(token.getIdentifier(),
                token.getKind().toString(), token.getPassword(),
                token.getService().toString());
          }
        }
      }

      RMAppMetrics rmAppMetrics = getRMAppMetrics();
      appUsageReport.setMemorySeconds(rmAppMetrics.getMemorySeconds());
      appUsageReport.setVcoreSeconds(rmAppMetrics.getVcoreSeconds());
    }

    if (currentApplicationAttemptId == null) {
      currentApplicationAttemptId = 
          BuilderUtils.newApplicationAttemptId(this.applicationId, 
              DUMMY_APPLICATION_ATTEMPT_NUMBER);
    }

    return BuilderUtils.newApplicationReport(this.applicationId,
        currentApplicationAttemptId, this.user, this.queue,
        this.name, host, rpcPort, clientToAMToken,
        createApplicationState(), diags,
        trackingUrl, this.startTime, this.finishTime, finishState,
        appUsageReport, origTrackingUrl, progress, this.applicationType, 
        amrmToken, applicationTags);
  } finally {
    this.readLock.unlock();
  }
}