Java Code Examples for org.apache.hadoop.yarn.security.AMRMTokenIdentifier#getApplicationAttemptId()

The following examples show how to use org.apache.hadoop.yarn.security.AMRMTokenIdentifier#getApplicationAttemptId() . 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: AMRMTokenSecretManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the password for the given {@link AMRMTokenIdentifier}.
 * Used by RPC layer to validate a remote {@link AMRMTokenIdentifier}.
 */
@Override
public byte[] retrievePassword(AMRMTokenIdentifier identifier)
    throws InvalidToken {
  this.readLock.lock();
  try {
    ApplicationAttemptId applicationAttemptId =
        identifier.getApplicationAttemptId();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Trying to retrieve password for " + applicationAttemptId);
    }
    if (!appAttemptSet.contains(applicationAttemptId)) {
      throw new InvalidToken(applicationAttemptId
          + " not found in AMRMTokenSecretManager.");
    }
    if (identifier.getKeyId() == this.currentMasterKey.getMasterKey()
      .getKeyId()) {
      return createPassword(identifier.getBytes(),
        this.currentMasterKey.getSecretKey());
    } else if (nextMasterKey != null
        && identifier.getKeyId() == this.nextMasterKey.getMasterKey()
          .getKeyId()) {
      return createPassword(identifier.getBytes(),
        this.nextMasterKey.getSecretKey());
    }
    throw new InvalidToken("Invalid AMRMToken from " + applicationAttemptId);
  } finally {
    this.readLock.unlock();
  }
}
 
Example 2
Source File: AMRMTokenSecretManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
@Private
protected byte[] createPassword(AMRMTokenIdentifier identifier) {
  this.readLock.lock();
  try {
    ApplicationAttemptId applicationAttemptId =
        identifier.getApplicationAttemptId();
    LOG.info("Creating password for " + applicationAttemptId);
    return createPassword(identifier.getBytes(), getMasterKey()
      .getSecretKey());
  } finally {
    this.readLock.unlock();
  }
}
 
Example 3
Source File: AMRMTokenSecretManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the password for the given {@link AMRMTokenIdentifier}.
 * Used by RPC layer to validate a remote {@link AMRMTokenIdentifier}.
 */
@Override
public byte[] retrievePassword(AMRMTokenIdentifier identifier)
    throws InvalidToken {
  this.readLock.lock();
  try {
    ApplicationAttemptId applicationAttemptId =
        identifier.getApplicationAttemptId();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Trying to retrieve password for " + applicationAttemptId);
    }
    if (!appAttemptSet.contains(applicationAttemptId)) {
      throw new InvalidToken(applicationAttemptId
          + " not found in AMRMTokenSecretManager.");
    }
    if (identifier.getKeyId() == this.currentMasterKey.getMasterKey()
      .getKeyId()) {
      return createPassword(identifier.getBytes(),
        this.currentMasterKey.getSecretKey());
    } else if (nextMasterKey != null
        && identifier.getKeyId() == this.nextMasterKey.getMasterKey()
          .getKeyId()) {
      return createPassword(identifier.getBytes(),
        this.nextMasterKey.getSecretKey());
    }
    throw new InvalidToken("Invalid AMRMToken from " + applicationAttemptId);
  } finally {
    this.readLock.unlock();
  }
}
 
Example 4
Source File: AMRMTokenSecretManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
@Private
protected byte[] createPassword(AMRMTokenIdentifier identifier) {
  this.readLock.lock();
  try {
    ApplicationAttemptId applicationAttemptId =
        identifier.getApplicationAttemptId();
    LOG.info("Creating password for " + applicationAttemptId);
    return createPassword(identifier.getBytes(), getMasterKey()
      .getSecretKey());
  } finally {
    this.readLock.unlock();
  }
}