Search in sources :

Example 1 with AMRMProxyTokenSecretManager

use of org.apache.hadoop.yarn.server.nodemanager.amrmproxy.AMRMProxyTokenSecretManager in project hadoop by apache.

the class BaseAMRMProxyE2ETest method createAMRMProtocol.

protected ApplicationMasterProtocol createAMRMProtocol(YarnClient rmClient, ApplicationId appId, MiniYARNCluster cluster, final Configuration yarnConf) throws IOException, InterruptedException, YarnException {
    UserGroupInformation user = null;
    // Get the AMRMToken from AMRMProxy
    ApplicationReport report = rmClient.getApplicationReport(appId);
    user = UserGroupInformation.createProxyUser(report.getCurrentApplicationAttemptId().toString(), UserGroupInformation.getCurrentUser());
    ContainerManagerImpl containerManager = (ContainerManagerImpl) cluster.getNodeManager(0).getNMContext().getContainerManager();
    AMRMProxyTokenSecretManager amrmTokenSecretManager = containerManager.getAMRMProxyService().getSecretManager();
    org.apache.hadoop.security.token.Token<AMRMTokenIdentifier> token = amrmTokenSecretManager.createAndGetAMRMToken(report.getCurrentApplicationAttemptId());
    SecurityUtil.setTokenService(token, containerManager.getAMRMProxyService().getBindAddress());
    user.addToken(token);
    return user.doAs(new PrivilegedExceptionAction<ApplicationMasterProtocol>() {

        @Override
        public ApplicationMasterProtocol run() throws Exception {
            return ClientRMProxy.createRMProxy(yarnConf, ApplicationMasterProtocol.class);
        }
    });
}
Also used : AMRMProxyTokenSecretManager(org.apache.hadoop.yarn.server.nodemanager.amrmproxy.AMRMProxyTokenSecretManager) ApplicationMasterProtocol(org.apache.hadoop.yarn.api.ApplicationMasterProtocol) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ContainerManagerImpl(org.apache.hadoop.yarn.server.nodemanager.containermanager.ContainerManagerImpl) AMRMTokenIdentifier(org.apache.hadoop.yarn.security.AMRMTokenIdentifier) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

IOException (java.io.IOException)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 ApplicationMasterProtocol (org.apache.hadoop.yarn.api.ApplicationMasterProtocol)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 AMRMTokenIdentifier (org.apache.hadoop.yarn.security.AMRMTokenIdentifier)1 AMRMProxyTokenSecretManager (org.apache.hadoop.yarn.server.nodemanager.amrmproxy.AMRMProxyTokenSecretManager)1 ContainerManagerImpl (org.apache.hadoop.yarn.server.nodemanager.containermanager.ContainerManagerImpl)1