@Override public org.apache.hadoop.yarn.api.records.Token getRMDelegationToken( Text renewer) throws YarnException, IOException { return client.getRMDelegationToken(renewer); }
@Override public org.apache.hadoop.yarn.api.records.Token getRMDelegationToken( Text renewer) throws YarnException, IOException { return client.getRMDelegationToken(renewer); }
@SuppressWarnings("rawtypes") public Token getDelegationToken(Text renewer) throws IOException, InterruptedException { try { // Remove rmAddress after YARN-868 is addressed return ConverterUtils.convertFromYarn( client.getRMDelegationToken(renewer), rmAddress); } catch (YarnException e) { throw new IOException(e); } }
@SuppressWarnings("rawtypes") public Token getDelegationToken(Text renewer) throws IOException, InterruptedException { try { return ConverterUtils.convertFromYarn( client.getRMDelegationToken(renewer), getRMDelegationTokenService()); } catch (YarnException e) { throw new IOException(e); } }
@SuppressWarnings("rawtypes") public Token getDelegationToken(Text renewer) throws IOException, InterruptedException { try { return ConverterUtils.convertFromYarn( client.getRMDelegationToken(renewer), getRMDelegationTokenService()); } catch (YarnException e) { throw new IOException(e); } }
public void addRMDelegationToken(final String renewer, final Credentials credentials) throws IOException, YarnException { // Get the ResourceManager delegation rmToken final org.apache.hadoop.yarn.api.records.Token rmDelegationToken = clientRM.getRMDelegationToken(new Text(renewer)); Token<RMDelegationTokenIdentifier> token; // TODO: Use the utility method getRMDelegationTokenService in ClientRMProxy to remove the separate handling of // TODO: HA and non-HA cases when hadoop dependency is changed to hadoop 2.4 or above if (ConfigUtils.isRMHAEnabled(conf)) { LOG.info("Yarn Resource Manager HA is enabled"); token = getRMHAToken(rmDelegationToken); } else { LOG.info("Yarn Resource Manager HA is not enabled"); InetSocketAddress rmAddress = conf.getSocketAddr(YarnConfiguration.RM_ADDRESS, YarnConfiguration.DEFAULT_RM_ADDRESS, YarnConfiguration.DEFAULT_RM_PORT); token = ConverterUtils.convertFromYarn(rmDelegationToken, rmAddress); } LOG.info("RM dt {}", token); credentials.addToken(token.getService(), token); }
throw new RuntimeException("Failed to get RM principal."); final Token<?> rmToken = ConverterUtils.convertFromYarn(yarnClient.getRMDelegationToken(new Text(tokenRenewer)), yarnConf.getSocketAddr(YarnConfiguration.RM_ADDRESS, YarnConfiguration.DEFAULT_RM_ADDRESS,
org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);
org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);
org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);
/** * Create and add an RM delegation token to the credentials * @param yarnClient Yarn Client * @param credentials to add token to * @return the token which was added * @throws IOException * @throws YarnException */ public static Token<TokenIdentifier> addRMDelegationToken(YarnClient yarnClient, Credentials credentials) throws IOException, YarnException { Configuration conf = yarnClient.getConfig(); Text rmPrincipal = new Text(CredentialUtils.getRMPrincipal(conf)); Text rmDTService = ClientRMProxy.getRMDelegationTokenService(conf); Token<TokenIdentifier> rmDelegationToken = ConverterUtils.convertFromYarn( yarnClient.getRMDelegationToken(rmPrincipal), rmDTService); credentials.addToken(rmDelegationToken.getService(), rmDelegationToken); return rmDelegationToken; }
org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(renewer);
/** * Create and add an RM delegation token to the credentials * @param yarnClient Yarn Client * @param credentials to add token to * @return the token which was added * @throws IOException * @throws YarnException */ public static Token<TokenIdentifier> addRMDelegationToken(YarnClient yarnClient, Credentials credentials) throws IOException, YarnException { Configuration conf = yarnClient.getConfig(); Text rmPrincipal = new Text(CredentialUtils.getRMPrincipal(conf)); Text rmDTService = ClientRMProxy.getRMDelegationTokenService(conf); Token<TokenIdentifier> rmDelegationToken = ConverterUtils.convertFromYarn( yarnClient.getRMDelegationToken(rmPrincipal), rmDTService); credentials.addToken(rmDelegationToken.getService(), rmDelegationToken); return rmDelegationToken; }
/** * Adds RM delegation token to the given {@link ContainerLaunchContext} so that the AM can authenticate itself * with RM using the delegation token. */ protected void addRMToken(ContainerLaunchContext context, YarnClient yarnClient, ApplicationId appId) { if (!UserGroupInformation.isSecurityEnabled()) { return; } try { Credentials credentials = YarnUtils.decodeCredentials(context.getTokens()); Configuration config = yarnClient.getConfig(); Token<TokenIdentifier> token = ConverterUtils.convertFromYarn( yarnClient.getRMDelegationToken(new Text(YarnUtils.getYarnTokenRenewer(config))), YarnUtils.getRMAddress(config)); LOG.debug("Added RM delegation token {} for application {}", token, appId); credentials.addToken(token.getService(), token); context.setTokens(YarnUtils.encodeCredentials(credentials)); } catch (YarnException | IOException e) { throw new RuntimeException("Failed to acquire RM delegation token", e); } }
/** * Adds RM delegation token to the given {@link ContainerLaunchContext} so that the AM can authenticate itself * with RM using the delegation token. */ protected void addRMToken(ContainerLaunchContext context, YarnClient yarnClient, ApplicationId appId) { if (!UserGroupInformation.isSecurityEnabled()) { return; } try { Credentials credentials = YarnUtils.decodeCredentials(context.getTokens()); Configuration config = yarnClient.getConfig(); Token<TokenIdentifier> token = ConverterUtils.convertFromYarn( yarnClient.getRMDelegationToken(new Text(YarnUtils.getYarnTokenRenewer(config))), YarnUtils.getRMAddress(config)); LOG.debug("Added RM delegation token {} for application {}", token, appId); credentials.addToken(token.getService(), token); context.setTokens(YarnUtils.encodeCredentials(credentials)); } catch (YarnException | IOException e) { throw new RuntimeException("Failed to acquire RM delegation token", e); } }
/** * Add an RM_DELEGATION_TOKEN to the {@link Credentials} provided. * * @param credentials the credentials object which is updated * @param config launcher AM configuration * @param props properties for getting credential token or certificate * @param context workflow context * @throws Exception thrown if failed */ @Override public void updateCredentials(Credentials credentials, Configuration config, CredentialsProperties props, ActionExecutor.Context context) throws Exception { Text rmDelegationTokenService = ClientRMProxy.getRMDelegationTokenService(config); if (rmDelegationTokenService == null) { throw new CredentialException(ErrorCode.E0512, "Can't create RMDelegationTokenService"); } try (YarnClient yarnClient = Services.get().get(HadoopAccessorService.class) .createYarnClient(context.getWorkflow().getUser(), config)) { org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(new Text(new HadoopTokenHelper().getServerPrincipal(config))); if (rmDelegationToken == null) { throw new CredentialException(ErrorCode.E0512, "Returned token is null"); } Token<TokenIdentifier> rmToken = ConverterUtils.convertFromYarn(rmDelegationToken, rmDelegationTokenService); credentials.addToken(rmDelegationTokenService, rmToken); } catch (Exception e) { XLog.getLog(getClass()).debug("Exception in updateCredentials", e); throw e; } }
/** * Add an RM_DELEGATION_TOKEN to the {@link Credentials} provided. * * @param credentials the credentials object which is updated * @param config launcher AM configuration * @param props properties for getting credential token or certificate * @param context workflow context * @throws Exception thrown if failed */ @Override public void updateCredentials(Credentials credentials, Configuration config, CredentialsProperties props, ActionExecutor.Context context) throws Exception { Text rmDelegationTokenService = ClientRMProxy.getRMDelegationTokenService(config); if (rmDelegationTokenService == null) { throw new CredentialException(ErrorCode.E0512, "Can't create RMDelegationTokenService"); } try (YarnClient yarnClient = Services.get().get(HadoopAccessorService.class) .createYarnClient(context.getWorkflow().getUser(), config)) { org.apache.hadoop.yarn.api.records.Token rmDelegationToken = yarnClient.getRMDelegationToken(new Text(new HadoopTokenHelper().getServerPrincipal(config))); if (rmDelegationToken == null) { throw new CredentialException(ErrorCode.E0512, "Returned token is null"); } Token<TokenIdentifier> rmToken = ConverterUtils.convertFromYarn(rmDelegationToken, rmDelegationTokenService); credentials.addToken(rmDelegationTokenService, rmToken); } catch (Exception e) { XLog.getLog(getClass()).debug("Exception in updateCredentials", e); throw e; } }