Search in sources :

Example 21 with DataInputByteBuffer

use of org.apache.hadoop.io.DataInputByteBuffer in project hadoop by apache.

the class YarnServerSecurityUtils method parseCredentials.

/**
   * Parses the container launch context and returns a Credential instance that
   * contains all the tokens from the launch context. 
   * @param launchContext
   * @return the credential instance
   * @throws IOException
   */
public static Credentials parseCredentials(ContainerLaunchContext launchContext) throws IOException {
    Credentials credentials = new Credentials();
    ByteBuffer tokens = launchContext.getTokens();
    if (tokens != null) {
        DataInputByteBuffer buf = new DataInputByteBuffer();
        tokens.rewind();
        buf.reset(tokens);
        credentials.readTokenStorageStream(buf);
        if (LOG.isDebugEnabled()) {
            for (Token<? extends TokenIdentifier> tk : credentials.getAllTokens()) {
                LOG.debug(tk.getService() + " = " + tk.toString());
            }
        }
    }
    return credentials;
}
Also used : DataInputByteBuffer(org.apache.hadoop.io.DataInputByteBuffer) ByteBuffer(java.nio.ByteBuffer) DataInputByteBuffer(org.apache.hadoop.io.DataInputByteBuffer) Credentials(org.apache.hadoop.security.Credentials)

Aggregations

DataInputByteBuffer (org.apache.hadoop.io.DataInputByteBuffer)21 Credentials (org.apache.hadoop.security.Credentials)12 ByteBuffer (java.nio.ByteBuffer)10 Token (org.apache.hadoop.security.token.Token)8 Test (org.junit.Test)8 Text (org.apache.hadoop.io.Text)5 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)4 IOException (java.io.IOException)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Configuration (org.apache.hadoop.conf.Configuration)3 DelegationTokenIdentifier (org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier)3 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)3 DataOutputByteBuffer (org.apache.hadoop.io.DataOutputByteBuffer)3 InvalidToken (org.apache.hadoop.security.token.SecretManager.InvalidToken)3 ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)3 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)3 NodeHeartbeatResponse (org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse)3 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)3 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)3 TestSecurityMockRM (org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM)3