Search in sources :

Example 56 with YarnRPC

use of org.apache.hadoop.yarn.ipc.YarnRPC in project oozie by apache.

the class JHSCredentials method instantiateHistoryProxy.

/**
 * Create an MRClientProtocol to the JHS
 * Copied over from ClientCache in Hadoop.
 * @return the protocol that can be used to get a token with
 * @throws IOException
 */
private MRClientProtocol instantiateHistoryProxy(final Configuration configuration, final ActionExecutor.Context context) throws IOException {
    final String serviceAddr = configuration.get(JHAdminConfig.MR_HISTORY_ADDRESS);
    if (StringUtils.isEmpty(serviceAddr)) {
        return null;
    }
    LOG.debug("Connecting to JHS at: " + serviceAddr);
    final YarnRPC rpc = YarnRPC.create(configuration);
    LOG.debug("Connected to JHS at: " + serviceAddr);
    UserGroupInformation currentUser = Services.get().get(UserGroupInformationService.class).getProxyUser(context.getWorkflow().getUser());
    return currentUser.doAs(new PrivilegedAction<MRClientProtocol>() {

        @Override
        public MRClientProtocol run() {
            return (MRClientProtocol) rpc.getProxy(HSClientProtocol.class, NetUtils.createSocketAddr(serviceAddr), configuration);
        }
    });
}
Also used : UserGroupInformationService(org.apache.oozie.service.UserGroupInformationService) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) MRClientProtocol(org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)

Aggregations

YarnRPC (org.apache.hadoop.yarn.ipc.YarnRPC)56 Configuration (org.apache.hadoop.conf.Configuration)39 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)38 InetSocketAddress (java.net.InetSocketAddress)34 Test (org.junit.Test)18 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)15 IOException (java.io.IOException)14 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)12 NodeId (org.apache.hadoop.yarn.api.records.NodeId)12 MRClientProtocol (org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)8 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)8 ContainerManagementProtocol (org.apache.hadoop.yarn.api.ContainerManagementProtocol)8 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)8 HashMap (java.util.HashMap)7 Server (org.apache.hadoop.ipc.Server)7 ApplicationMasterProtocol (org.apache.hadoop.yarn.api.ApplicationMasterProtocol)7 RegisterApplicationMasterRequest (org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest)7 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)7 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)7 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)7