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);
}
});
}
Aggregations