Search in sources :

Example 11 with ClientToAMTokenIdentifier

use of org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier in project tez by apache.

the class TezClientUtils method getAMProxy.

@Private
public static DAGClientAMProtocolBlockingPB getAMProxy(final Configuration conf, String amHost, int amRpcPort, org.apache.hadoop.yarn.api.records.Token clientToAMToken) throws IOException {
    final InetSocketAddress serviceAddr = NetUtils.createSocketAddrForHost(amHost, amRpcPort);
    UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(UserGroupInformation.getCurrentUser().getUserName());
    if (clientToAMToken != null) {
        Token<ClientToAMTokenIdentifier> token = ConverterUtils.convertFromYarn(clientToAMToken, serviceAddr);
        userUgi.addToken(token);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Connecting to Tez AM at " + serviceAddr);
    }
    DAGClientAMProtocolBlockingPB proxy = null;
    try {
        proxy = userUgi.doAs(new PrivilegedExceptionAction<DAGClientAMProtocolBlockingPB>() {

            @Override
            public DAGClientAMProtocolBlockingPB run() throws IOException {
                RPC.setProtocolEngine(conf, DAGClientAMProtocolBlockingPB.class, ProtobufRpcEngine.class);
                return (DAGClientAMProtocolBlockingPB) RPC.getProxy(DAGClientAMProtocolBlockingPB.class, 0, serviceAddr, conf);
            }
        });
    } catch (InterruptedException e) {
        throw new IOException("Failed to connect to AM", e);
    }
    return proxy;
}
Also used : ClientToAMTokenIdentifier(org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier) DAGClientAMProtocolBlockingPB(org.apache.tez.dag.api.client.rpc.DAGClientAMProtocolBlockingPB) InetSocketAddress(java.net.InetSocketAddress) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Aggregations

ClientToAMTokenIdentifier (org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier)11 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)7 IOException (java.io.IOException)5 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)4 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)4 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)4 Test (org.junit.Test)4 ServiceException (com.google.protobuf.ServiceException)3 SaslException (javax.security.sasl.SaslException)3 RemoteException (org.apache.hadoop.ipc.RemoteException)3 InetSocketAddress (java.net.InetSocketAddress)2 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 ContainerManagementProtocol (org.apache.hadoop.yarn.api.ContainerManagementProtocol)2 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)2 GetApplicationReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse)2 RegisterApplicationMasterResponse (org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse)2 StartContainersResponse (org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse)2 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)2 ClientRMService (org.apache.hadoop.yarn.server.resourcemanager.ClientRMService)2 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)2